Command Causing Server Crash -
SupperRobin6394 - 22.12.2015
Hey hey,
I got quite a lot of problems with my Server, one of the Commands is causing a crash:
Код:
[23:49:58] [debug] Server crashed while executing RobinMode.amx
[23:49:58] [debug] AMX backtrace:
[23:49:58] [debug] #0 00000073 in ?? () from RobinMode.amx
[23:49:58] [debug] #1 00000073 in public cmd_asay () from RobinMode.amx
[23:49:58] [debug] #2 native CallLocalFunction () from sampsvr-port_2470
[23:49:58] [debug] #3 000111dc in public KB_OnPlayerCommandText (0, 1433272) from RobinMode.amx
[23:49:58] [debug] #4 00004dd0 in public OnPlayerCommandText (0, 1433272) from RobinMode.amx
This is the Command that is causing it:
PHP код:
COMMAND:asay(playerid, params[])
{
if(level[playerid] == 6)
{
new pid, towhat;
if(sscanf(params, "us", pid, towhat)) return SendClientMessage(playerid, COLOR_RED, "Usage: /asay [PlayerID] [Text]");
{
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not online.");
new string[180];
format(string, sizeof(string), "%s", towhat);
SendPlayerMessageToAll(pid, string);
printf("%s",string);
}
}
else return 0;
return 1;
}
Any ideas?
Re: Command Causing Server Crash -
saffierr - 22.12.2015
I don't see anything strange in the command...
Re: Command Causing Server Crash -
J0sh... - 22.12.2015
Have you compiled using the -d3 parameter?
Re: Command Causing Server Crash -
SupperRobin6394 - 22.12.2015
Quote:
Originally Posted by Jamester
Have you compiled using the -d3 parameter?
|
The what? I don't know what you mean.
I got the latest Includes etc, nothing with that (in case you meant that).
Re: Command Causing Server Crash -
TwinkiDaBoss - 22.12.2015
Use this.
PHP код:
COMMAND:asay(playerid, params[])
{
if(level[playerid] != 6) return SendClientMessage(playerid,COLOR_RED,"You are not admin level 6");
new pid, towhat[64];
if(sscanf(params, "us[64]", pid, towhat)) return SendClientMessage(playerid, COLOR_RED, "Usage: /asay [PlayerID] [Text]");
new string[128];
format(string, sizeof(string), "%s", towhat);
SendClientMessage(pid,COLOR_RED, string);
return true;
}
EDIT: Fixed the pid. Forgot to add it
Re: Command Causing Server Crash -
SupperRobin6394 - 22.12.2015
Quote:
Originally Posted by TwinkiDaBoss
Use this.
PHP код:
COMMAND:asay(playerid, params[])
{
if(level[playerid] != 6) return SendClientMessage(playerid,COLOR_RED,"You are not admin level 6");
new pid, towhat[64];
if(sscanf(params, "us[64]", pid, towhat)) return SendClientMessage(playerid, COLOR_RED, "Usage: /asay [PlayerID] [Text]");
new string[128];
format(string, sizeof(string), "%s", towhat);
SendClientMessage(pid,COLOR_RED, string);
return true;
}
EDIT: Fixed the pid. Forgot to add it
|
This keeps returning me the Usage message...
Re: Command Causing Server Crash -
TwinkiDaBoss - 22.12.2015
Quote:
Originally Posted by SupperRobin6394
This keeps returning me the Usage message...
|
Update your sscanf or something. The code should work normaly
Re: Command Causing Server Crash -
SupperRobin6394 - 22.12.2015
Quote:
Originally Posted by TwinkiDaBoss
Update your sscanf or something. The code should work normaly
|
Lmao it's working after updating it!
Can you explain my what changed that caused it to be solved so I can do it myself next time?
Re: Command Causing Server Crash -
TwinkiDaBoss - 22.12.2015
1. ToWhat <- Should be a string "towhat[size] >> towhat[64]"
2. What was the point of return 0? Dont use return 0 if you dont know what it does
3. SendPlayerMessageToAll(pid, string); you are sending message to all, usage COLOR,Message, but you were entering their ID in first parameter instead.
4. sscanf was missing string size. Ie : "us" isnt valid, "us[64]" is valid.
Aka
PHP код:
new pid, towhat; //To what should be a string as you want to format it and ask player to input text
if(sscanf(params, "us", pid, towhat)) //Again, ToWhat is set as intergrer but it should be a string, ie "us[size]" < meaning "us[64]"
else return 0; //else to do what? return 0? Why?
Return 0 can be used in situations such as
If you put return 0 in OnPlayerRequestClass the player wont spawn.