#1

Hey!!

I have question. I have this command:
pawn Код:
if(strcmp(cmdtext, "/sf", true) == 0)
    {
        SetTimerEx("SFtele",5000,false,"i",playerid);
        SendClientMessage(playerid, COLOR_WHITE,"** Wait 5 seconds...");
        return 1;
    }
When time is up there is this thing
pawn Код:
public SFtele(playerid)
{
//there is my things and stuff.
    return 1;
}
Okey now to the question. How to stop timer. like im on the foot i type /sf and timer starts in that time i jump in the car and when im in car timer stops like nothing happened. i dont need that car getting in stuff just how to stop timer without executing public SFtele. i hope you understand me.

Thanks a lot for help!
Reply
#2

pawn Код:
KillTimer(SFtele[playerid]);
Reply
#3

Thanks! Solved.
Reply
#4

Glad I could help!
Reply
#5

by the way.. i done it like that.
Onthetop
pawn Код:
new teleSF;
Onplayercommandtext
pawn Код:
if(strcmp(cmdtext, "/sf", true) == 0)
    {
        teleSF = SetTimerEx("SFtele",5000,false,"i",playerid);
        SendClientMessage(playerid, COLOR_WHITE,"** Wait 5 seconds...");
        return 1;
    }
onplayerstatechange
pawn Код:
KillTimer(teleSF);
Twisted insane - your way didnt work. It kills timer and doing command instantly. But thanks for help. appreciate every reply with attempts to help.
Reply
#6

Why didn't it work and why you did put the piece under "OnPlayerStateChange"? Try to put it under your forwarded public, in this case, under "public SFTele"....
Reply
#7

Also, show us your OnPlayerStateChange.
pawn Код:
new
    teleSF[ MAX_PLAYERS ]
;
pawn Код:
if( !strcmp( cmdtext, "/sf", true ) )
{
    teleSF[ playerid ] = SetTimerEx( "SFtele", 5000, false, "i", playerid );
   
    SendClientMessage( playerid, COLOR_WHITE,"** Wait 5 seconds..." );

    return 1;
}
pawn Код:
KillTimer( teleSF[ playerid ] );
EDIT: What he wants is, when someone types this command and enter a car before five seconds pass, it will kill the timer and won't execute the public.
Reply
#8

Like i said. it did command instantly. i just wanted to make killtimer to stop the timer and dont do command.
and why under on player state change? Its for car export. i made it like when you are in exportable car you cant teleport but my little brother found bug that if you type teleport command /sf before you enter the vehicle and then enter in vehicle you can teleport. so i needed it to put underonplayerstatechange.

EDIT: Yup. Toreno, that what i typed working. but why need max_players and stuff? your way is better? im just learning...
Reply
#9

Quote:
Originally Posted by bleedis
Посмотреть сообщение
Like i said. it did command instantly. i just wanted to make killtimer to stop the timer and dont do command.
and why under on player state change? Its for car export. i made it like when you are in exportable car you cant teleport but my little brother found bug that if you type teleport command /sf before you enter the vehicle and then enter in vehicle you can teleport. so i needed it to put underonplayerstatechange.
Exactly what I said in my EDIT post, anyway, mind showing us your OnPlayerStateChange public?
Reply
#10

Sure. Why?
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
        switch(newstate)
    {
        case PLAYER_STATE_PASSENGER:
        {
            if(GetPlayerWeapon(playerid) == 24 ) SetPlayerArmedWeapon(playerid,0);
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER)

    {
        if (locked[playerid][vehid[playerid]] == 1)
            {
                unlocktimer = SetTimerEx("unlock",300000,false,"ii",playerid,vehid[playerid]);
                locked[playerid][vehid[playerid]] = 2;
            }
    }
    if (newstate == PLAYER_STATE_DRIVER)
    {
    SetPlayerArmedWeapon(playerid, 0);
        if (locked[playerid][vehid[playerid]] == 2)
        {
            KillTimer(unlocktimer);
            locked[playerid][vehid[playerid]] = 1;
            new Float:pX, Float:pY, Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            PlayerPlaySound(playerid,1056,pX,pY,pZ);
            SendClientMessage(playerid,COLOR_RED,"** This vehicle is locked.");
        }
        new newcar = GetPlayerVehicleID(playerid);
        new model = GetVehicleModel(newcar);
        if (model == carselect[0] || model == carselect[1] || model == carselect[2])
        {
            KillTimer(teleLS);
            KillTimer(teleLV);
            KillTimer(teleSF);
            KillTimer(teleCHILLIAD);
            KillTimer(teleDRIFTLS);
            KillTimer(teleDRIFTSF);
            KillTimer(teleDRIFTLV);
            KillTimer(teleARCH);
            KillTimer(teleTRANS);
            MiniMission[playerid] = CHECKPOINT_EXPORT;
            SetTimer("ShowCheckpoint", 1000, 1);
            SendClientMessage(playerid,COLOR_ORANGE,"You can export this vehicle in San Fierro!");
            }
     }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)