Author Topic: Bomb Da Base Timer  (Read 3343 times)

88nateatx

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +2/-7
  • Doesn't give a damn about his bad reputation.
    • View Profile
Bomb Da Base Timer
« on: November 02, 2011, 11: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 )

Code: [Select]
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 );
}


VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Re: Bomb Da Base Timer
« Reply #1 on: November 02, 2011, 12:00:09 pm »
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.


VetalYA

  • Guest
Re: Bomb Da Base Timer
« Reply #2 on: November 02, 2011, 01:26:34 pm »
Code: [Select]
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");   }

« Last Edit: November 02, 2011, 05:00:04 pm by VetalYA »

VetalYA

  • Guest
Re: Bomb Da Base Timer
« Reply #3 on: November 02, 2011, 04:43:50 pm »
Also to avoid server crash (if player who wait for the Detonator - leave the server)
add this code

Code: [Select]
function onPlayerPart( pPlayer, reason )
{
if(g_pPlayerID == pPlayer.ID){ g_pEntered <- 0;  g_pPlayerID <- 255;  }
return 1;
}

88nateatx

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +2/-7
  • Doesn't give a damn about his bad reputation.
    • View Profile
Re: Bomb Da Base Timer
« Reply #4 on: November 02, 2011, 10:12:20 pm »
Whoa, VetalYA, that's some awesome code right there.
Thanks for the help!  ;D ( I suck at timers anyways lol )


 

© Liberty Unleashed Team.