Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Creating a First Login (https://forums.graalonline.com/forums/showthread.php?t=134260289)

iSlayer 08-23-2010 02:59 AM

Creating a First Login
 
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

MrOmega 08-23-2010 03:03 AM

function onPlayerOnline(). think there may be a function onPlayerLogin().

fowlplay4 08-23-2010 03:12 AM

You put the code in the Control-NPC:

PHP Code:

function onActionPlayerOnline() {
  
// Code here..



iSlayer 08-23-2010 03:14 AM

And then it will work?

MrOmega 08-23-2010 03:27 AM

Maybe onActionPlayerOnline, but as one scripter to another try first, if you fail then ask for help, not will it work then, I know I got a lot hell from people when I did that when I started scripting, ( my favorite teacher Inverness mostly. :P)

Skyld 08-23-2010 10:41 AM

Quote:

Originally Posted by iSlayer (Post 1595918)
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 =.


All times are GMT +2. The time now is 10:22 AM.

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