View Single Post
  #6  
Old 08-23-2010, 10:41 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by iSlayer View Post
Well I posted a thread a while back about function firstLogin(pl) but i was told that theres no inbuilt command for it so I made this script

PHP Code:
function onPlayerOnline() {
  if(
clientr.firstlogin true) {
    
clientr.firstlogin false;
    
// Adds all the default flags
  
} else {
    
destroy();
  }

Will this work correctly? And if not how can i improve it
Firstly, clientr.firstlogin will not be true unless you set it, because like firstLogin(), it isn't a built-in object.

Secondly, there is reverse logic here. Because flags are unset by default, you should be checking that a flag isn't set and then set it once you have added all the default flags.

Thirdly, do not use destroy(), because if you put that in your Control-NPC (or any other database NPC), the NPC will destroy itself from the server every time your flag is not met. You don't need an else condition; don't put it there if you don't need it.

And finally, you compare flags using == and you assign flags using =.
__________________
Skyld
Reply With Quote