Server crashing cause of this command -
fiki574 - 21.12.2011
pawn Код:
COMMAND:me(playerid, params[])
{
new string;
if(sscanf(params, "s", string)) return SendClientMessage(playerid, GCOLOR_RED, "Usage: /me [activity]");
new domsg[256], PName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PName, sizeof(PName));
format(domsg, sizeof(domsg), "* %s is %s", PName, string);
SendClientMessageToAll(GCOLOR_WHITE, domsg);
return 1;
}
When I use this command, server instantly crashes! I am on linux, have downloaded latest sscanf (which is fixed for 0.3d) but still crashing! Is this command/script or sscanf fault?
P.S. Works perfectly on Windows server!
Re: Server crashing cause of this command -
kizla - 21.12.2011
pawn Код:
COMMAND:me(playerid, params[])
{
new string[128];
if(sscanf(params, "s[128]", string)) return SendClientMessage(playerid, GCOLOR_RED, "Usage: /me [activity]");
new domsg[128], PName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PName, sizeof(PName));
format(domsg, sizeof(domsg), "* %s is %s", PName, string);
SendClientMessageToAll(GCOLOR_WHITE, domsg);
return 1;
}
here you go
Re: Server crashing cause of this command -
Tee - 21.12.2011
Quote:
Originally Posted by kizla
pawn Код:
COMMAND:me(playerid, params[]) { new string[128]; if(sscanf(params, "s[128]", string)) return SendClientMessage(playerid, GCOLOR_RED, "Usage: /me [activity]"); new domsg[256], PName[MAX_PLAYER_NAME]; GetPlayerName(playerid, PName, sizeof(PName)); format(domsg, sizeof(domsg), "* %s is %s", PName, string); SendClientMessageToAll(GCOLOR_WHITE, domsg); return 1; }
here you go 
|
1. You don't have to make a new variable called "string" it's only 1 parameter, therefore just use "params"
2. "domsg[256]" You don't need 265 cells, the max string length in SA-MP is 128.
3. Code fixed below:
pawn Код:
COMMAND:me(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /me [activity]");
new domsg[128], PName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PName, sizeof(PName));
format(domsg, sizeof(domsg), "* %s is %s", PName, params);
SendClientMessageToAll(GCOLOR_WHITE, domsg);
return 1;
}
Re: Server crashing cause of this command -
fiki574 - 21.12.2011
Quote:
Originally Posted by Tee
1. You don't have to make a new variable called "string" it's only 1 parameter, therefore just use "params"
2. "domsg[256]" You don't need 265 cells, the max string length in SA-MP is 128.
3. Code fixed below:
pawn Код:
COMMAND:me(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /me [activity]"); new domsg[128], PName[MAX_PLAYER_NAME]; GetPlayerName(playerid, PName, sizeof(PName)); format(domsg, sizeof(domsg), "* %s is %s", PName, params); SendClientMessageToAll(GCOLOR_WHITE, domsg); return 1; }
|
Got 1 error, I know why!
Anyway, i used (!strval(params)) but it would return "Usage: /me activity"!
Re: Server crashing cause of this command -
kizla - 21.12.2011
Quote:
Originally Posted by Tee
2. "domsg[256]" You don't need 265 cells, the max string length in SA-MP is 128.
|
I now, but i just copy and past script and fix sscanf, i didnt fix the length of string..
Re: Server crashing cause of this command -
Tee - 21.12.2011
Quote:
Originally Posted by fiki574_CRO
Got 1 error, I know why!
Anyway, i used (!strval(params)) but it would return "Usage: /me activity"!
|
What's the error?
Re: Server crashing cause of this command -
fiki574 - 21.12.2011
Quote:
Originally Posted by Tee
What's the error?
|
undefined symbol "isnull"
Re: Server crashing cause of this command -
Tee - 21.12.2011
That's weird because you have the zcmd include right?
Re: Server crashing cause of this command -
fiki574 - 21.12.2011
Quote:
Originally Posted by Tee
That's weird because you have the zcmd include right?
|
Yes!
Re: Server crashing cause of this command -
kizla - 21.12.2011
Quote:
Originally Posted by fiki574_CRO
Yes!
|
you probably chaning some things in ZCMD include