Help with MYSQL
#1

Hello guys, I'm trying to make two commands for admins
1st: /stafflist (Which will get the name of all the admins and there levels)
2nd: /aka (which will get the name of all the players which are on the same IP)
Idk the query to make
I know that the query for a regular thing without sending it to client is
PHP код:
 SELECT * FROM `playerdata` WHERE playerLevel  >= 1 
But how to echo it
Those are the cmds i tried to make
PHP код:
 {
    new 
message[2500], sql[200], value[100][50];
    if(
playerData[playerid][playerScore] >= 50)
    {
        
format(sql, sizeof(sql), "SELECT * FROM `playerdata` WHERE playerLevel  >= 1");
        
mysql_query(sql);
        
mysql_store_result();
        if(
mysql_num_rows())
        {
            
mysql_fetch_row(value[5], "playerLevel");
            
mysql_fetch_row(value[0], "playerName");
            
format(message, sizeof(message), "%s{0000BB}%s", message, value[0]);
            
format(message, sizeof(message), "%sLevel: %s", message, value[5]);
            
ShowPlayerDialog(playerid, 10000, DIALOG_STYLE_MSGBOX, "Staff List", message, "Close", "");
        }
    }
    else
    {
        
SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FF0000}You must have 50 score in order to view the stafflist.");
    }
    return 
1;
} 
PHP код:
COMMAND:aka(playerid, params[])
{
    if(
playerData[playerid][playerLoggedIn])
    {
        if(
playerData[playerid][playerLevel] >= 1)
        {
            new
            
pIP[40],
            
otherID,
            
str[130],
            
str1[130],
           
// row[200],
            
value[100][50]
            ;
            if(
sscanf(params, "u", otherID))
            {
                
SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FFFFFF}Usage: /aka <playername/id>");
            }
            else
            {
                if(
IsPlayerConnected(otherID))
                {
                    if(
playerData[otherID][playerLoggedIn])
                    {
                           
GetPlayerIp(otherID, pIP, sizeof(pIP));
                        
format(str, sizeof(str), "SELECT `playerName`,`playerIP` FROM `playerdata` where `playerIP` = %s", pIP);
                        
mysql_query(str);
                        
mysql_fetch_row(value[0], "playerName");
                        
format(str1, sizeof(str1), "{AFAFAF}[SERVER] {FFFFFF}The AKA on the IP %s are: %s\n", pIP, value[0]);
                        
ShowPlayerDialog(playerid, 123, DIALOG_STYLE_LIST," {FFFFFF}-{00FF00}Accounts On Player Ip", str1, "Okay", "");
                        
mysql_free_result();
                    }
                    else
                    {
                        
SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FFFFFF}That player is not logged in.");
                    }
                }
                else
                {
                    
SendClientMessage(playerid, -1, "That player is not logged in.");
                }
            }
        }
        else
        {
            
SendClientMessage(playerid, -1, "{FF0000}[ERROR]{FFFFFF} You're not authorized to use this command.");
        }
    }
    else
    {
        
SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FFFFFF}You must be logged in to use commands.");
    }
    return 
1;
} 
Reply
#2

bump
Reply
#3

Are you using CZ CnR script, If yes then i can help you in PM.
Reply
#4

try this for staff command

PHP код:
CMD:staff(playerid)
{
    new 
message[2500], sql[200], value[100][50];
    if(
playerData[playerid][playerScore] >= 50)
    {
        
format(sql, sizeof(sql), "SELECT * FROM `playerdata` WHERE playerLevel  >= 1");
        
mysql_query(sql);
        
mysql_store_result();
        while(
mysql_retrieve_row())
        {
            
mysql_fetch_row(value[5], "playerLevel");
            
mysql_fetch_row(value[0], "playerName");
            
format(message, sizeof(message), "%s{0000BB}%s\tLevel: %s", message, value[0], value[5]);
        }
        
mysql_free_result();
        
ShowPlayerDialog(playerid, 10000, DIALOG_STYLE_MSGBOX, "Staff List", message, "Close", "");
    }
    else
    {
        
SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FF0000}You must have 50 score in order to view the stafflist.");
    }
    return 
1;
} 
Reply
#5

Which MySQL Version are you using? I could help you more if I know the MySQL Version.
Reply
#6

@GTLS
R41 please help me fast i need it
Reply
#7

@LevelT
It says
PHP код:
error 017: undefined symbol "mysql_retrieve_row"
error 027: invalid character constant
error 027
: invalid character constant 
Any Help please?
Reply
#8

pawn Код:
[debug] Run time error 19: "File or function is not found"
[04:40:19] [debug]  mysql_store_result
[04:40:19] [debug]  mysql_fetch_field
[04:40:19] [debug]  mysql_free_result
[04:40:19] [debug]  mysql_real_escape_string
[04:40:19] [debug]  mysql_fetch_row
[04:40:19] [debug]  mysql_num_rows
[04:40:19] [debug]  mysql_insert_id
[04:40:19] [debug]  mysql_retrieve_row
Mysql R41 Loaded but with this..
Server logs:
PHP код:
SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team
[04:40:19] 
[
04:40:19] Server Plugins
[04:40:19] --------------
[
04:40:19]  Loading plugin: crashdetect
[04:40:19]   crashdetect v4.8.5 is OK.
[
04:40:19]   Loaded.
[
04:40:19]  Loading plugin: mysql
[04:40:19]  >> plugin.mysql: R41-4 successfully loaded.
[
04:40:19]   Loaded.
[
04:40:19]  Loading plugin: sscanf
[04:40:19] 
[
04:40:19]  ===============================
[
04:40:19]       sscanf plugin loaded.     
[
04:40:19]          Version:  2.8.1        
[04:40:19]    (c) 2012 Alex "******" Cole  
[04:40:19]  ===============================
[
04:40:19]   Loaded.
[
04:40:19]  Loading plugin: streamer
[04:40:19]   Loaded.
[
04:40:19]  Loaded 4 plugins.
[
04:40:19] 
[
04:40:19] Ban list
[
04:40:19] --------
[
04:40:19]  Loaded: samp.ban
[04:40:19] 
[
04:40:19] 
[
04:40:19] Filterscripts
[04:40:19] ---------------
[
04:40:19]   Loading filterscript 'antirapidfire.amx'...
[
04:40:19]   Loading filterscript 'lab.amx'...
[
04:40:19]   Loading filterscript 'stunt.amx'...
[
04:40:19]   Loading filterscript 'shouryamaps.amx'...
[
04:40:19]   Loaded 4 filterscripts.
[
04:40:19] [debug] Run time error 19: "File or function is not found"
[04:40:19] [debug]  mysql_store_result
[04:40:19] [debug]  mysql_fetch_field
[04:40:19] [debug]  mysql_free_result
[04:40:19] [debug]  mysql_real_escape_string
[04:40:19] [debug]  mysql_fetch_row
[04:40:19] [debug]  mysql_num_rows
[04:40:19] [debug]  mysql_insert_id
[04:40:19] [debug]  mysql_retrieve_row
[04:40:19] Script[gamemodes/CnR1.amx]: Run time error 19: "File or function is not found"
[04:40:19] Number of vehicle models: 0 
Why?
please help
Reply
#9

in your script you using an old MySQL
Download the old version of MySQL or update your script to the latest MySQL version
Reply
#10

+slawi
What should i update in my script?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)