Liberty Unleashed
Scripting => Script Help => Topic started by: 88nateatx on November 02, 2011, 10:50:34 am
-
I'm working for a timer for a "Bomb Da Base" Server, and I was wondering...what did I do wrong here?
I'm trying to make it so that whenever you stand in a sphere for 5 seconds you get a Detonator, and when you leave it stops the timer, and insults you ( :P )
function onPlayerEnterSphere( player, sphere )
{
NewTimer( GetDetonator, 5000, 1 );
}
function onPlayerExitSphere( player, sphere )
{
MessagePlayer( "Fine, run away, you coward!", player );
Timer.Stop;
return 1;
}
function GetDetonator ( player )
{
MessagePlayer( "=You got the Detonator, Kid! Get off the boat and blow this joint!=", player, 255, 0, 0 );
Message( "="+ player + "'s got the Detonator!=", 255, 0, 0 );
player.SetWeapon( 12, 1 );
}
-
My squirrel is a bit rusty... but this looks like your problem:
NewTimer( GetDetonator, 5000, 1 );
Shouldn't it be NewTimer( "GetDetonator", 5000, 1 ); since NewTimers first argument is supposed to be a string.
-
g_pPlayerID <- 255;
g_pEntered <- 0;
g_pTimer <- 0;
function onPlayerEnterSphere( pPlayer, sphere )
{
if(g_pEntered == 1){
MessagePlayer("Sorry, but another one person is ALREADY trying to get a Detonator !, Please wait 5 sec and re-enter to checkpoint", pPlayer ); }
if(g_pEntered == 0){
g_pPlayerID <- pPlayer.ID; g_pEntered <- 1;
g_pTimer <- NewTimer( "GetDetonator", 5000, 1, pPlayer);
Message( pPlayer.Name + " is trying to get a Detonator !"); }
return 1;
}
function onPlayerExitSphere( pPlayer, sphere )
{
if(g_pPlayerID == pPlayer.ID){
MessagePlayer( "Fine, run away, you coward!", pPlayer );
g_pEntered <- 0; g_pPlayerID <- 255; g_pTimer.Delete; }
return 1;
}
function GetDetonator ( pPlayer )
{
if(g_pEntered == 0){ return false; } //Player will get nothing because he came out from the Sphere
MessagePlayer( "=You got the Detonator, Kid! Get off the boat and blow this joint!=", pPlayer, Colour( 255, 0, 0 ));
Message( "="+ pPlayer + "'s got the Detonator!=", 255, 0, 0 );
pPlayer.SetWeapon( 12, 1 );
g_pPlayerID <- 255; g_pEntered <- 0;
}
function onServerStart() { print("Everything is OK"); }
-
Also to avoid server crash (if player who wait for the Detonator - leave the server)
add this code
function onPlayerPart( pPlayer, reason )
{
if(g_pPlayerID == pPlayer.ID){ g_pEntered <- 0; g_pPlayerID <- 255; }
return 1;
}
-
Whoa, VetalYA, that's some awesome code right there.
Thanks for the help! ;D ( I suck at timers anyways lol )