SA-MP Forums Archive
SetTimerEx not forwarding the correct playerid. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SetTimerEx not forwarding the correct playerid. (/showthread.php?tid=433449)



SetTimerEx not forwarding the correct playerid. - techg9 - 27.04.2013

Hey guys,
I build a timer that needs to forward the playerid, and when I test is, it gives the playerid 102 and mine is 4.

beware I defined in my script all the parameters.

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
     if (
PRESSEDKEY_FIRE ))
    {
        new
        
Float:x,
        
Float:y,
        
Float:z;
            
ICDV[playerid] = 2;
        
ICD[playerid] = SetTimerEx("ICountDown"1001"i""f""f""f"playeridxyz);
    }
    return 
1;

PHP код:
forward ICountDown(playeridxyz);
public 
ICountDown(playeridxyz)
{
    
ICDV[playerid]--;
    new 
str[128]; // for testing the bug
    
format(str,sizeof(str),"ICDV:%d | playerid:%d"ICDV[playerid], playerid); // for testing the bug
    
SendClientMessageToAll(LightBluestr); // for testing the bug
    
if(ICDV[playerid] == 0)
    {
        
KillTimer(ICD[playerid]);
    }
    return 
1;

Someone knows why it sends me the playerid 102 and not my playerid 4?
Thanks for the help =)


Re: SetTimerEx not forwarding the correct playerid. - PT - 27.04.2013

Hello

I don't understand what you want, but it is this?

pawn Код:
new     Float:x,  // top of GameMode
        Float:y,
        Float:z;

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED( KEY_FIRE ))
    {
        ICDV[playerid] = 2;
        ICD[playerid] = SetTimerEx("ICountDown", 100, false, "d", playerid);
    }
    return 1;
}  

forward ICountDown(playerid);
public ICountDown(playerid)
{
    GetPlayerPos(playerid, x, y, z);
    ICDV[playerid]--;
    {
        new str[128];
        format(str,sizeof(str),"ICDV:%d | playerid:%d", ICDV[playerid], playerid);
        SendClientMessageToAll(0xFFFFFFAA, str);
    }
    if(ICDV[playerid] == 0)
    {
        KillTimer(ICD[playerid]);
    }
    return 1;
}
PT


Re: SetTimerEx not forwarding the correct playerid. - MattyG - 27.04.2013

Your line:
pawn Код:
ICD[playerid] = SetTimerEx("ICountDown", 100, 1, "i", "f", "f", "f", playerid, x, y, z);
Should be:
pawn Код:
ICD[playerid] = SetTimerEx("ICountDown", 100, 1, "ifff", playerid, x, y, z);
This is because the parameters are:
Код:
(funcname[], interval, repeating, const format[], {Float,_}:...)
So your const format[] is kind of like using format.


Re: SetTimerEx not forwarding the correct playerid. - techg9 - 27.04.2013

Quote:
Originally Posted by MattyG
Посмотреть сообщение
Your line:
pawn Код:
ICD[playerid] = SetTimerEx("ICountDown", 100, 1, "i", "f", "f", "f", playerid, x, y, z);
Should be:
pawn Код:
ICD[playerid] = SetTimerEx("ICountDown", 100, 1, "ifff", playerid, x, y, z);
This is because the parameters are:
Код:
(funcname[], interval, repeating, const format[], {Float,_}:...)
So your const format[] is kind of like using format.
oh. thanks man =) +rep