Help | Command problem
#1

when i do the command that turns on the countdown public it supposed to send a message every second like :
PHP код:
"[%s] GMX in %d" 
%s = sendername
%d = cd
now , the sendername always catches the name of id 0 in the server and not the real sendername..
please help !!


PHP код:
forward CountDown(cd);
public 
CountDown(cd)
{
    new 
playerid;
    new 
sendername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    new 
cdt[32];
    
format(cdtsizeof(cdt), "~b~GMX ~g~in ~y~%d"cd);
    
GameTextForAll(cdt10003);
    
format(cdtsizeof(cdt), "[%s] GMX in %d"sendernamecd);
    
SendClientMessageToAll(COLOR_REDcdt);
    if(
cd 1)
    {
       
cd--;
       
GMXCD SetTimerEx("CountDown"10000"%d"cd);
    }
    else
    {
       
GameTextForAll("~r~GMX"10003);
       
SendClientMessageToAll(COLOR_BLUE"{FF0000}GMX");
       
SendClientMessageToAll(COLOR_BLUE"{1100FF}GMX");
       
SendClientMessageToAll(COLOR_BLUE"{E6FF00}GMX");
       
SendClientMessageToAll(COLOR_BLUE"{FF0000}G{1100FF}M{E6FF00}X");
       
SendClientMessageToAll(COLOR_BLUE"{E6FF00}G{FF0000}M{1100FF}X");
       
SendClientMessageToAll(COLOR_BLUE"{1100FF}G{E6FF00}M{FF0000}X");
       
SendClientMessageToAll(COLOR_BLUE"{E6FF00}GMX");
       
SendClientMessageToAll(COLOR_BLUE"{1100FF}GMX");
       
SendClientMessageToAll(COLOR_BLUE"{FF0000}GMX");
       
GameModeExit();
    }

Reply
#2

That's because you create the variable playerid in the function.
If you create a new variable it's always 0;

Try to add playerid in the function.
I fixed it for you.
Modify the functions you already have in your script, and it should work fine

pawn Код:
forward CountDown(cd, playerid);
public CountDown(cd, playerid)
{
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new cdt[32];
    format(cdt, sizeof(cdt), "~b~GMX ~g~in ~y~%d", cd);
    GameTextForAll(cdt, 1000, 3);
    format(cdt, sizeof(cdt), "[%s] GMX in %d", sendername, cd);
    SendClientMessageToAll(COLOR_RED, cdt);
    if(cd > 1)
    {
       cd--;
       GMXCD = SetTimerEx("CountDown", 1000, 0, "%d", cd);
    }
    else
    {
       GameTextForAll("~r~GMX", 1000, 3);
       SendClientMessageToAll(COLOR_BLUE, "{FF0000}GMX");
       SendClientMessageToAll(COLOR_BLUE, "{1100FF}GMX");
       SendClientMessageToAll(COLOR_BLUE, "{E6FF00}GMX");
       SendClientMessageToAll(COLOR_BLUE, "{FF0000}G{1100FF}M{E6FF00}X");
       SendClientMessageToAll(COLOR_BLUE, "{E6FF00}G{FF0000}M{1100FF}X");
       SendClientMessageToAll(COLOR_BLUE, "{1100FF}G{E6FF00}M{FF0000}X");
       SendClientMessageToAll(COLOR_BLUE, "{E6FF00}GMX");
       SendClientMessageToAll(COLOR_BLUE, "{1100FF}GMX");
       SendClientMessageToAll(COLOR_BLUE, "{FF0000}GMX");
       GameModeExit();
    }
}
Reply
#3

1 Warning (how to fix it )

PHP код:
C:\Users\User\Desktop\Universal Mode\Multi.pwn(40792) : warning 202number of arguments does not match definition 
There's the command: (Line 40784 - 40797)

PHP код:
    if (strcmp(cmd"/GMXCD"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pAdmin] >= 1338)
            {
                
tmp strtok(cmdtextidx);
                if(!
strlen(tmp))return SendClientMessage(playerid0xFFFFFFAA"USAGE: /GMXCD [Count]");
                
CountDown(strval(tmp));
                return 
1;
            }
        }
          return 
1;
    } 
Reply
#4

Change CountDown(strval(tmp)); to CountDown(strval(tmp),playerid)j
Reply
#5

Quote:
Originally Posted by AeroBlast
Посмотреть сообщение
Change CountDown(strval(tmp)); to CountDown(strval(tmp),playerid)j
Working, but just in the first message only it shows the sendername:

Example:

PHP код:
[Diego_ElkaponGMX in 10 
and after a second it dissapears like:

PHP код:
[] GMX in 9 
PHP код:
[] GMX in 8 
and etc..
Reply
#6

Update
pawn Код:
if(cd > 1)
    {
       cd--;
       GMXCD = SetTimerEx("CountDown", 1000, 0, "%d", cd);
    }
into:
pawn Код:
if(cd > 1)
    {
       cd--;
       GMXCD = SetTimerEx("CountDown", 1000, 0, "di", cd, playerid);
    }
Should be working properly now.
Reply
#7

Quote:
Originally Posted by SVRP
Посмотреть сообщение
Update
pawn Код:
if(cd > 1)
    {
       cd--;
       GMXCD = SetTimerEx("CountDown", 1000, 0, "%d", cd);
    }
into:
pawn Код:
if(cd > 1)
    {
       cd--;
       GMXCD = SetTimerEx("CountDown", 1000, 0, "di", cd, playerid);
    }
Should be working properly now.
Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)