MySQL big problem
#1

Okay so I have new problem
I made another acc on localhost and it is created in DB. Problem is when I give myself an admin on one acc another acc is getting the same admin level. Before making second acc /setmoney worked fine. Now it won't add at all. I just have same ammout on both accs.. Here are /setmoney and /setadmin

PHP код:
CMD:setmoney(playeridparams[]) 

    if(
PlayerInfo[playerid][Admin] < 4
    { 
        
ERROR(playerid"You are not allowed to use this command"); 
        return 
1
    } 
    new 
targetammount
    if(
sscanf(params"ui"targetammount)) 
    { 
        
USAGE(playerid"/setmoney [ID/Name] [Ammount]"); 
        return 
1
    } 
    if(!
IsPlayerConnected(target)) 
    { 
        
ERROR(playerid"That player is not connected"); 
        return 
1
    } 
    
ResetPlayerMoney(target); 
    
GivePlayerMoney(targetammount); 
    
PlayerInfo[target][Money] = ammount
    new 
string[128], string2[128], query[90]; 
    
format(stringsizeof(string), ""YELLOW"[INFO] "WHITE"Admin "SERVERBLUE"%s "WHITE"setted your money to "SERVERBLUE"%d"GetName(playerid), ammount); 
    
SCM(target, -1string); 
    
format(string2sizeof(string2), "[INFO] Admin %s setted %s %d$"GetName(playerid), GetName(target), ammount); 
    
AdminMessage(-1string2); 
    
WriteLog(MONEYstring2); 
    
mysql_format(g_SQLquerysizeof(query), "UPDATE `players` SET `Money` = %d WHERE `ID` = %d LIMIT 1"ammountPlayerInfo[target][ID]); 
    
mysql_tquery(g_SQLquery); 
    return 
1

//=============================== Admin Level 5 ================================// 
CMD:setadmin(playeridparams[]) 

    if(
PlayerInfo[playerid][Admin] < 5
    { 
        
ERROR(playerid"You are not allowed to use this command"); 
        return 
1
    } 
    new 
targetlevel
    if(
sscanf(params"ui"targetlevel)) 
    { 
        
USAGE(playerid"/setadmin [ID/Name] [Level]"); 
        return 
1
    } 
    if(!
IsPlayerConnected(target)) 
    { 
        
ERROR(playerid"That player is not online"); 
        return 
1
    } 
    if(
PlayerInfo[target][Admin] >= 1
    { 
        
ERROR(playerid"That player already has that admin level. Use /apromote or /ademote"); 
        return 
1
    } 
    
PlayerInfo[target][Admin] = level
    new 
string[128], string2[128], query[128]; 
    
mysql_format(g_SQLquerysizeof(query), "UPDATE `players` SET `Admin` = %d WHERE `ID` = %d LIMIT 1"levelPlayerInfo[playerid][ID]); 
    
mysql_tquery(g_SQLquery); 
    
format(stringsizeof(string), ""YELLOW"[INFO] "WHITE"Admin "SERVERBLUE"%s "WHITE" gave you Admin Level "SERVERBLUE"%d"GetName(playerid), level); 
    
SCM(target, -1string); 
    
format(string2sizeof(string2), "[INFO] Admin %s gave %s Admin Level %d"GetName(playerid), GetName(target), level); 
    
AdminMessage(-1string2); 
    
WriteLog(SETstring2); 
    return 
1

Reply
#2

Okay this for admins is fixed. But money command is not working.. It gives me money but it won't update it in db
PHP код:
CMD:setmoney(playeridparams[])
{
    if(
PlayerInfo[playerid][Admin] < 4)
    {
        
ERROR(playerid"You are not allowed to use this command");
        return 
1;
    }
    new 
targetammount;
    if(
sscanf(params"ui"targetammount))
    {
        
USAGE(playerid"/setmoney [ID/Name] [Ammount]");
        return 
1;
    }
    if(!
IsPlayerConnected(target))
    {
        
ERROR(playerid"That player is not connected");
        return 
1;
    }
    
ResetPlayerMoney(target);
    
GivePlayerMoney(targetammount);
    
PlayerInfo[target][Money] = ammount;
    new 
string[128], string2[128], query[128];
    
format(stringsizeof(string), ""YELLOW"[INFO] "WHITE"Admin "SERVERBLUE"%s "WHITE"setted your money to "SERVERBLUE"%d"GetName(playerid), ammount);
    
SCM(target, -1string);
    
format(string2sizeof(string2), "[INFO] Admin %s setted %s %d$"GetName(playerid), GetName(target), ammount);
    
AdminMessage(-1string2);
    
WriteLog(MONEYstring2);
    
mysql_format(g_SQLquerysizeof(query), "UPDATE `players` SET `Money` = %d WHERE `ID` = %d LIMIT 1"ammountPlayerInfo[target][ID]);
    
mysql_tquery(g_SQLquery);
    return 
1;

EDIT
I found this in log
Код:
08:34:48] [ERROR] error #1064 while executing query "UPDATE `players` SET `OrgJoined` = 3 `OrgLeader` = 3 `OrgRank` = 6 WHERE `ID` = 2 LIMIT 1": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`OrgLeader` = 3 `OrgRank` = 6 WHERE `ID` = 2 LIMIT 1' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:2003)
[08:35:18] [WARNING] mysql_connect: no password specified (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:160)
[08:35:50] [ERROR] cache_get_value_name: field 'password' not found (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:591)
[08:35:50] [ERROR] cache_get_value_name: field 'salt' not found (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:592)
[08:36:01] [ERROR] error #1064 while executing query "UPDATE `players` SET `OrgJoined` = 3 `OrgLeader` = 3 `OrgRank` = 6 WHERE `ID` = 2 LIMIT 1": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`OrgLeader` = 3 `OrgRank` = 6 WHERE `ID` = 2 LIMIT 1' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:2003)
[08:36:17] [WARNING] mysql_connect: no password specified (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:160)
[08:36:51] [ERROR] cache_get_value_name: field 'password' not found (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:591)
[08:36:51] [ERROR] cache_get_value_name: field 'salt' not found (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:592)
There is tons of these.. Any ideas?
Reply
#3

Код:
SET `OrgJoined` = 3, `OrgLeader` = 3, `OrgRank` = 6
Tou need to put , between orgjoin ,orgleader etc
As far i know
https://www.techonthenet.com/mysql/update.php
Reply
#4

Thx I fixed that but now I am confused about this /setmoney.. I just don't get it
Reply
#5

FIXED!
Problem was that in tables I've put tinyint for money instead of int so it couldn't update more money than 127 xD Thx for help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)