SA-MP Forums Archive
Whats wrong ? - 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: Whats wrong ? (/showthread.php?tid=550447)



Whats wrong ? - Jhony_Blaze - 12.12.2014

Hey, I am trying to make a simple "afk" command so if I type it, it will send out that " %s player is away from keyboard!"

This is what I've done:

Код:
COMMAND:afk(playerid,params[])
{
    new string[125]
    format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
    return 1;
}
Errors:

Код:
(14214) : error 001: expected token: ";", but found "-identifier-"
(14214) : error 012: invalid function call, not a valid address
(14214) : warning 215: expression has no effect
(14214) : error 001: expected token: ";", but found ")"
(14214) : fatal error 107: too many error messages on one line



Re: Whats wrong ? - lulo356 - 12.12.2014

Here
pawn Код:
COMMAND:afk(playerid,params[])
{
    new string[125];
    format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
    return 1;
}
pawn Код:
COMMAND:afk(playerid,params[])
{
    new string[125];
    format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
    SendAdminMessage(COLOR_RED, 1, string); // maybe usefull
    return 1;
}



Re: Whats wrong ? - DaTa[X] - 12.12.2014

pawn Код:
COMMAND:afk(playerid,params[])
{
    new string[125];
    format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
    return 1;
}



Re: Whats wrong ? - Jhony_Blaze - 12.12.2014

You guys sent me the same stuff I did and I said it has errors :/


Re: Whats wrong ? - lulo356 - 12.12.2014

Quote:
Originally Posted by Jhony_Blaze
Посмотреть сообщение
You guys sent me the same stuff I did and I said it has errors :/
You had this
pawn Код:
new string[125]
But you forgot to place the ; at the end of the line so we changed it to
pawn Код:
new string[125];



Re: Whats wrong ? - Jhony_Blaze - 12.12.2014

Oh yeah, sorry, but I still get the same errors ...


Re: Whats wrong ? - lulo356 - 12.12.2014

You got this
pawn Код:
COMMAND:afk(playerid,params[])
{
    new string[125];
    format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
    return 1;
}
Update it to this
pawn Код:
COMMAND:afk(playerid,params[])
{
    new string[125];
    format(string, sizeof(string),"{2641FEFF} You have set your self Away from keyboard!",);
    SendClientMessage(playerid, COLOR_RED, string);
    return 1;
}
And if it is for admins

pawn Код:
COMMAND:afk(playerid,params[])
{
    new string[125];
    format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
    SendAdminMessage(COLOR_RED, 1, string);
    return 1;
}



Re: Whats wrong ? - Jhony_Blaze - 12.12.2014

Its alright now. Thanks !


Re: Whats wrong ? - lulo356 - 12.12.2014

Quote:
Originally Posted by Jhony_Blaze
Посмотреть сообщение
I still got the same errors I think the problem is somewhere here :

Код:
format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
Send me the list of the errors


Re: Whats wrong ? - AdHaM612 - 12.12.2014

You have just formatted a string, without using it.
Change it to:
pawn Код:
COMMAND:afk(playerid,params[])
{
    new string[125];
    format(string, sizeof(string),"{2641FEFF} %s is away from keyboard!", PlayerName(playerid));
    SendClientMessageToAll(-1,string); // The message will be sent to all the players
    return 1;
}