Id 0 Command Processing
#1

Hello,

I'm in the process of creating a new script for my community. I have created an engine system using textdraws but for some reason teh command only works properly for id 0. What is the issue? Any help is appreciated!




Chains Community
Reply
#2

How about you show us the code?
Reply
#3

pawn Код:
if(strcmp(cmd, "/startengine",true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
            {
                GameTextForPlayer(playerid, " ~g~Starting....", 4000, 3);
                StartTimer = SetTimer("StartTime", 1000, 0);
            }
        }
        return 1;
    }
pawn Код:
public StartTime(playerid)
{
    KillTimer(StartTimer);
    StartTimer2 = SetTimer("StartTime2", 1000, 0);
    return 1;
}
There is more that includes our most unique feature but I wont include this part. I have already checked it and its good!
Reply
#4

Quote:
Originally Posted by Blade_Cervetti
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/startengine",true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
            {
                GameTextForPlayer(playerid, " ~g~Starting....", 4000, 3);
                StartTimer = SetTimer("StartTime", 1000, 0);
            }
        }
        return 1;
    }
pawn Код:
public StartTime(playerid)
{
    KillTimer(StartTimer);
    StartTimer2 = SetTimer("StartTime2", 1000, 0);
    return 1;
}
SetTimerEx()
Reply
#5

pawn Код:
if(strcmp(cmdtext, "/startengine", true) == 0)
Also, StartTime doesn't need the playerid parameter.
pawn Код:
public StartTime( )
Reply
#6

Could you explain the difference between SetTimer And SetTimerEx, wiki doesnt make any sense to me :P!
Reply
#7

SetTimerEx is used to pass extra parameters through the callback. For example, your example
StartTime( playerid ) - With SetTimerEx, you can pass the 'playerid' parameter. The format would be as so:
pawn Код:
SetTimerEx( "StartTime", 1000, false, "i", playerid );
// 1000 = time
// false = don't repeat
// "i" = the format (integer for 'playerid')
// playerid = the parameter to pass
It's hard to explain, but once you understand it, it's nothing!
Reply
#8

I think I understand it, Let me edit and I will repost the code and see fi it looks right then!

pawn Код:
public StartTime()
{
    KillTimer(StartTimer);
    StartTimer2 = SetTimerEx( "StartTime2", 1000, false, "i", playerid );
    return 1;
}
I am now getting undefined symbol "playerid". I'm sorry it's been a long time since I've scripted so I kindof forgot everything, it wil come back to me though, I hope :P!
Reply
#9

And can't you just set the timer rate to 2 seconds instead of 1 seconds. Since the only thing your timer does is to kill the current timer (wich would've ended anyway) and then start a new 1 second timer.. And then you can just remove the public "StartTime".
pawn Код:
if(strcmp(cmd, "/startengine",true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
            {
                GameTextForPlayer(playerid, " ~g~Starting....", 4000, 3);
                StartTimer2 = SetTimer("StartTime2", 2000, 0);
            }
        }
        return 1;
    }
Reply
#10

I updated my post~!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)