Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.