KillTimer
#1

Hello Dear Samp Members,

So my problem is when a player dies it dosent kill the timer when the timer anti team kill is still working for exsample
i spawn i get a 10 seconds anti spawn kill then i do /reclass quickly and the old timer dosent die and i get double times the ammo i need to get

here is my code
pawn Код:
CMD:reclass(playerid,params[])
{
    SetPlayerHealth(playerid,0);
    Assault[playerid] =0;
    Sniper[playerid] =0;
    Engineer[playerid] =0;
    Pilot[playerid] =0;
    Gunner[playerid] =0;
    onduty[playerid] =0;
    FirstSpawn[playerid] =0;
    KillTimer(EndSpawn(playerid));
    SendClientMessage(playerid,COLOR_ORANGE,"You are now sent to class selection");
    return 1;
}

here is the timer itself that i am calling
pawn Код:
else if(FirstSpawn[playerid] == 1)
    {
       SetTimerEx("EndSpawn", 10000, false, "i", playerid);
       SendClientMessage(playerid,COLOR_RED,"[DarkyBot]You have 10 seconds anti spawn kill");
    }
Reply
#2

That "KillTimer" line is not how timers work! Go read ANY other mode's code for examples.
Reply
#3

You need to define the timer you want to kill. This is the correct method I think.

pawn Код:
new endspawnTimer[MAX_PLAYERS];
pawn Код:
else if(FirstSpawn[playerid] == 1)
    {
        endspawnTimer[playerid] = SetTimerEx("EndSpawn", 10000, false, "i", playerid);
        SendClientMessage(playerid,COLOR_RED,"[DarkyBot]You have 10 seconds anti spawn kill");
    }
pawn Код:
KillTimer(endspawnTimer[playerid]);
Reply
#4

Its already defined as a public callback

here is the code
pawn Код:
forward EndSpawn(playerid);
public EndSpawn(playerid)
{
      if(Assault[playerid] == 1)
      {
       GivePlayerWeapon(playerid,4,0);
       GivePlayerWeapon(playerid,16,2);
       GivePlayerWeapon(playerid,23,400);
       GivePlayerWeapon(playerid,31,700);
       GivePlayerWeapon(playerid,46,1);
       SetPlayerHealth(playerid, 100);
       SendClientMessage(playerid,COLOR_RED,"[DarkyBot]Your anti spawn kill has ended");
      }
      if(Sniper[playerid] == 1)
      {
       GivePlayerWeapon(playerid,4,0);
       GivePlayerWeapon(playerid,24,500);
       GivePlayerWeapon(playerid,27,300);
       GivePlayerWeapon(playerid,34,500);
       for(new i = 0; i < MAX_PLAYERS; i++)
       {
           SetPlayerMarkerForPlayer( i, playerid, ( GetPlayerColor( 1 ) & 0xFFFFFF00 ) );
       }
       SetPlayerHealth(playerid, 100);
       SendClientMessage(playerid,COLOR_RED,"[DarkyBot]Your anti spawn kill has ended");
      }
      if(Engineer[playerid] == 1)
      {
       GivePlayerWeapon(playerid,24,500);
       GivePlayerWeapon(playerid,27,400);
       GivePlayerWeapon(playerid,28,600);
       GivePlayerWeapon(playerid,30,400);  
       SetPlayerHealth(playerid, 100);
       SendClientMessage(playerid,COLOR_RED,"[DarkyBot]Your anti spawn kill has ended");
      }
      if(Pilot[playerid] == 1)
      {
       GivePlayerWeapon(playerid,24,600);
       GivePlayerWeapon(playerid,26,280);
       GivePlayerWeapon(playerid,36,10);
       GivePlayerWeapon(playerid,31,500);
       SetPlayerHealth(playerid, 100);
       SendClientMessage(playerid,COLOR_RED,"[DarkyBot]Your anti spawn kill has ended");
      }
      if(Gunner[playerid] == 1)
      {
       GivePlayerWeapon(playerid,38,200);
       GivePlayerWeapon(playerid,26,500);
       GivePlayerWeapon(playerid,31,800);
       GivePlayerWeapon(playerid,36,30);
       SetPlayerHealth(playerid, 100);
       SendClientMessage(playerid,COLOR_RED,"[DarkyBot]Your anti spawn kill has ended");
      }        
   return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)