SetTimerEx not forwarding the correct playerid.
#1

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 =)
Reply
#2

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
Reply
#3

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.
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)