RCON Command Crashes Server
#1

Hello everyone,

I'm having trouble with the code below. It's basically a custom RCON command that is called via PHP script when player purchases something in game shop. However, my server randomly crashes after someone makes a payment (triggers the PHP script, which calls the RCON command). Server also crashed by typing this RCON command manually in-game, so I'm pretty sure that there's something wrong with the following code, I just don't see it.


This code is stored in a filterscript (because of OnRconCommand):
PHP код:
public OnRconCommand(cmd[])
{
    new 
cmdtext[128], params[128];
    
sscanf(cmd"s[128]s[128]"cmdtextparams);
    if(!
strcmp(cmdtext"givecredits30"true))
    {
        if(
isnull(params)) return print("RCON: null string called");
        new 
str[128];
        
format(strsizeof(str), "Player %s bought 30 credits."params);
        
printf("%s"str);
        if(!
isnull(params))
        {
            
CallRemoteFunction("Give30Credits""s"params); // //This public is placed in gamemode
        
}
        return 
1;
    }
    if(!
strcmp(cmdtext"givecredits100"true))
    {
        if(
isnull(params)) return print("RCON: null string called");
        new 
str[128];
        
format(strsizeof(str), "Player %s bought 100 credits."params);
        
printf("%s"str);
        if(!
isnull(params))
        {
            
CallRemoteFunction("Give100Credits""s"params); //This public is placed in gamemode
        
}
        return 
1;
    }
    return 
true;

Public that is called with "CallRemoteFunction":
PHP код:
forward Give30Credits(params[]);
public 
Give30Credits(params[])
{
    new 
bool:found=false;
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(!
strcmp(paramspName(i), false)) //Check if the player (name) is connected
        
{
            if(
logged[i] == 1)
            {
                if(
found == false)
                 { 
//Player is online
                    
ShowPlayerDialog(i0DIALOG_STYLE_MSGBOX"Hernн obchod""Zakoupena poloћka v hernнm obchodě: {FF33CC}30 Kreditů""Zavřнt",""); // Just some informational text, not in English
                    
found true;
                    
PlayerInfo[i][Credits] += 30;
                    
SaveCharacter(i);
                }
            }
        }
    }
    if(
found == false)  //If player isn't online
    
{
        new 
file[128];
        
format(filesizeof(file), "Users/%s.ini"params);
        if(
dini_Exists(file))
        {
            
dini_IntSet(file"Credits"dini_Int(file"Credits")+30);
            
dini_IntSet(file"BoughtCredits"30);
        }
    }
    return 
1;

Thank you in advance for any help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)