SA-MP Forums Archive
Server crashing cause of this command - 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: Server crashing cause of this command (/showthread.php?tid=305196)



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