SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/06/2018, 12:48 PM   #1
TheBeastKhan
Little Clucker
 
Join Date: May 2018
Posts: 36
Reputation: 0
Default Unknown Command

Code:
COMMAND:oban(playerid, params[])
{
    if(playerData[playerid][playerLoggedIn])
    {
        if(playerData[playerid][playerLevel] >= 4)
        {
            new otherPlayer[24], reason[50];
            if(sscanf(params, "s[50]s[50]", otherPlayer, reason)) return SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FFFFFF}Usage: /oban <playername> <reason>");
            {
                new mysql[150], value[100][50], row[200];
                format(mysql, sizeof(mysql), "SELECT * FROM `playerdata` WHERE `playerName` = '%s'", otherPlayer);
                mysql_query(mysql);
                mysql_store_result();


                if(mysql_num_rows())
                {
                    mysql_fetch_row(row, "|", connection);
                    explode(row, value, "|");
                    mysql_fetch_row(value[4], "playerIP");
                    new str[150];
                    format(str, sizeof(str), "SELECT * FROM `playerbans` WHERE `player_banned` = '%s'", otherPlayer);
                    mysql_query(str);
                    mysql_store_result();
                    if(mysql_num_rows())
                    {
                        SendClientMessage(playerid, -1, "{FF0000}[ERROR]{FFFFFF} This player is already banned.");
                        mysql_free_result();
                    }
                    else
                    {
                        new banreason[350], msg[250], msg1[250];
                        format(banreason, sizeof(banreason), "INSERT INTO `playerbans` (`banned_by`, `banned_for`, `player_banned`, `player_ip`) VALUES ('%s', '%s', '%s', '%s')", playerData[playerid][playerNamee], reason, otherPlayer, playerIP);
                        mysql_query(banreason);
                        format(msg, sizeof(msg), "{33AA33}[ADMIN] Adminstrator %s(%i) has offline banned %s. {FFFF00}[REASON: %s]", playerData[playerid][playerNamee], playerid, otherPlayer, reason);
                        SendClientMessageToAll(-1, msg);
                        format(msg1, sizeof(msg1), "{33AA33}[ADMIN]{FFFFFF} You've offline banned %s for %s.", otherPlayer, reason);
                        SendClientMessage(playerid, -1, msg1);

                        mysql_free_result();
                    }
                    mysql_free_result();
                }
                else
                {
                    SendClientMessage(playerid, -1, "{FF0000}[ERROR]{FFFFFF} That player doesn't exist in the database.");
                }
            }
        }
        else
        {
            TextDrawSetString(NotAuthorized, "You are not authorized to use this command!");
            TextDrawHideForPlayer(playerid, NotAuthorized);
            TextDrawShowForPlayer(playerid, NotAuthorized);
            SetTimerEx("una", 3000, false, "i", playerid);
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FFFFFF}You must be logged in to use commands.");
    }
    return 1;
}
On execution, it is showing Unknown Command rather than Ban ....
TheBeastKhan is offline   Reply With Quote
Old 13/06/2018, 03:46 PM   #2
TheBeastKhan
Little Clucker
 
Join Date: May 2018
Posts: 36
Reputation: 0
Default Re: Unknown Command

Bump
TheBeastKhan is offline   Reply With Quote
Old 13/06/2018, 04:18 PM   #3
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,479
Reputation: 525
Default Re: Unknown Command

Read the forum rules... 24 hour bumps only.
Sew_Sumi is offline   Reply With Quote
Old 13/06/2018, 04:51 PM   #4
GTLS
Gangsta
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 821
Reputation: 91
Default Re: Unknown Command

Use Crashdetect and post the server logs.
__________________

I don't help for rep. I help cuz I was helped in the past.


California State Roleplay - X Update Now under beta testing phase. Stay Tuned.
GTLS is offline   Reply With Quote
Old 14/06/2018, 12:28 PM   #5
TheBeastKhan
Little Clucker
 
Join Date: May 2018
Posts: 36
Reputation: 0
Default Re: Unknown Command

I am using crashdetect, Nothing in server logs -_-
TheBeastKhan is offline   Reply With Quote
Old 17/06/2018, 03:21 PM   #6
TheBeastKhan
Little Clucker
 
Join Date: May 2018
Posts: 36
Reputation: 0
Default Re: Unknown Command

bump, Please help me!
TheBeastKhan is offline   Reply With Quote
Old 17/06/2018, 10:43 PM   #7
Lucases
Huge Clucker
 
Join Date: Jul 2017
Posts: 227
Reputation: 11
Default Re: Unknown Command

Why are you using mysql_free_result inside the if statement and outside it?
Won't it try to free the result twice?
Lucases is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 1 20/04/2018 12:12 PM
Problem with command. Only returns Server: Unknown Command Knappen Scripting Help 9 18/12/2013 06:09 PM
[Command Bugged] Each time i use /respawnallcars it says Unknown Command Rand_Omar Scripting Help 11 30/09/2012 12:35 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 03:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 05:19 AM


All times are GMT. The time now is 12:52 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.