Server crashing cause of this command
#1

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!
Reply
#2

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
Reply
#3

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;
}
Reply
#4

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"!
Reply
#5

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..
Reply
#6

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?
Reply
#7

Quote:
Originally Posted by Tee
Посмотреть сообщение
What's the error?
undefined symbol "isnull"
Reply
#8

That's weird because you have the zcmd include right?
Reply
#9

Quote:
Originally Posted by Tee
Посмотреть сообщение
That's weird because you have the zcmd include right?
Yes!
Reply
#10

Quote:
Originally Posted by fiki574_CRO
Посмотреть сообщение
Yes!
you probably chaning some things in ZCMD include
Reply


Forum Jump:


Users browsing this thread: