Two simple script questions.

Forum Archive - from http://theuniversal.net
Locked
User avatar
Omni
Posts: 156
Joined: Sat Feb 25, 2012 11:07 am

Two simple script questions.

Post by Omni »

Simple, but endlessly useful.

I need to know what line of code you'd need to make the script recognise a certain player on login/landing and putting them in a specified vehicle (specified in the script).

So something like(pseudocode)::

Code: Select all

Event("PlayerLogin" 0)
{

If %PLAYER% is "Blaze"
{

*setvehicle %PLAYER% #
*say In soviet russia, you burn Blaze.

}


}
Didn't find it on the guides. I know zaroba has used it before, but hurricane sandy is gonna keep him "busy" for a while.

Here's another question, is there anyway, to make an *effect %player% # last constantly till the player logs off? Then start when the player logs on again?
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

you put this as the if line in script

Code: Select all

IF ($gPlayerID = #)
*showbill (player name)
to find the playerid# to put in it

it what im useing for persnal profiles and info on frost :)
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

forgot to say u may also want to add a sleep timer to it being the script will acualy run befor the player is fully on the world and wont efect them
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

Don't need that sleep stuff now, blaze, as theres a new event 'PlayerLoginComplete' that is run after the player is fully connected and able to receive messages etc.

So, heres your complete script..

Code: Select all

Event( "PlayerLoginComplete", "" )
{
    $blazesBillingID = sysGetPlayerID( "Blaze" )
    if ( $gPlayerID == $blazesBillingID )
    { 
        *setvehicle %PLAYER% # 
        *say In soviet russia, you burn Blaze. 
     }
} 
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

cool did not know that event was added thanks i have a use for that :P also wouldent this be more efenchent

Code: Select all

Event( "PlayerLoginComplete", "" ) 
 { 
   if ( $gPlayerID = # ) 
    { 
      *setvehicle %PLAYER% # 
      *say In soviet russia, you burn Blaze. 
     } 
 }
being that as scrips get bigger every bit halps when it comes to faster loadeing :)
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

knowing the ID number in advance would make it a lil more efficient yeh, but i just thought that made the example clearer and more useful :].
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

oh ok kool :)
User avatar
Omni
Posts: 156
Joined: Sat Feb 25, 2012 11:07 am

Post by Omni »

Thanks guys. Helping a lot.

Now for my other question:
Here's another question, is there anyway, to make an *effect %player% # last constantly till the player logs off? Then start when the player logs on again?
I know we don't have loops in Mit++, which would certainly make that possible. Is there another way?
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

something like this would loop for the efect ur looking for.

Code: Select all

event("playerlogin", " ")
 {
  *effect %player% #
  CustomEvent( "efect" )
 }


event("custom", "efect")
 {
  sleep( # )
   *effect %player% #
  CustomEvent( "efect" )
 }
just got to make shure the sleep timeer runs out just befor the efect runs out
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

Only problem with that is that it creates a new sequence of events every time someone logs in.. eventually your server will blow up :)

You need to make sure to turn it off when the player leaves (either by setting a variable in the PlayerLogout event or using sysIsPlayerIDOnline).
Personally i prefer timers to sleeps, so the code would be :

Code: Select all

Event( "PlayerLogin", "" )
{
    *effect %PLAYER% #
    $timerID = sysSetTimer( 10, "PlayerEffectTimer", "" )
}

Event( "Timer", "PlayerEffectTimer" )
{
    $isStillOnline = sysIsPlayerIDOnline( $gPlayerID )
    if ( $isStillOnline == 1 )
    {
        *effect %PLAYER% #
        $timerID = sysSetTimer( 10, "PlayerEffectTimer", "" )
    }
}
(10 in that example is the number of seconds between each timer event)
Last edited by Mit on Fri Nov 02, 2012 1:30 am, edited 1 time in total.
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

i like that. i had not evan been thinking of checking if still online
Locked