Command Causing Server Crash
#1

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(playeridparams[])
{
    if(
level[playerid] == 6)
    {
        new 
pidtowhat;
        if(
sscanf(params"us"pidtowhat)) return SendClientMessage(playeridCOLOR_RED"Usage: /asay [PlayerID] [Text]");
        {
            if(!
IsPlayerConnected(pid)) return SendClientMessage(playeridCOLOR_RED"ERROR: That player is not online.");
            new 
string[180];
            
format(stringsizeof(string), "%s"towhat);
            
SendPlayerMessageToAll(pidstring);
            
printf("%s",string);
        }
    }
    else return 
0;
    return 
1;

Any ideas?
Reply
#2

I don't see anything strange in the command...
Reply
#3

Have you compiled using the -d3 parameter?
Reply
#4

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).
Reply
#5

Use this.

PHP код:
COMMAND:asay(playeridparams[])
{
    if(
level[playerid] != 6) return SendClientMessage(playerid,COLOR_RED,"You are not admin level 6");
    new 
pidtowhat[64];
    if(
sscanf(params"us[64]"pidtowhat)) return SendClientMessage(playeridCOLOR_RED"Usage: /asay [PlayerID] [Text]");
    
    new 
string[128];
    
format(stringsizeof(string), "%s"towhat);
    
SendClientMessage(pid,COLOR_REDstring);
    return 
true;

EDIT: Fixed the pid. Forgot to add it
Reply
#6

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Use this.

PHP код:
COMMAND:asay(playeridparams[])
{
    if(
level[playerid] != 6) return SendClientMessage(playerid,COLOR_RED,"You are not admin level 6");
    new 
pidtowhat[64];
    if(
sscanf(params"us[64]"pidtowhat)) return SendClientMessage(playeridCOLOR_RED"Usage: /asay [PlayerID] [Text]");
    
    new 
string[128];
    
format(stringsizeof(string), "%s"towhat);
    
SendClientMessage(pid,COLOR_REDstring);
    return 
true;

EDIT: Fixed the pid. Forgot to add it
This keeps returning me the Usage message...
Reply
#7

Quote:
Originally Posted by SupperRobin6394
Посмотреть сообщение
This keeps returning me the Usage message...
Update your sscanf or something. The code should work normaly
Reply
#8

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

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 pidtowhat//To what should be a string as you want to format it and ask player to input text
if(sscanf(params"us"pidtowhat)) //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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)