SA-MP Forums Archive
Everytime a player logins, these 2 variables changes to a fixed value - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Everytime a player logins, these 2 variables changes to a fixed value (/showthread.php?tid=653807)



Everytime a player logins, these 2 variables changes to a fixed value - cristiifrim - 13.05.2018

On my login system(mysql r39-6), whenever a player logins these 2 variables(Playa[playerid][Level], Playa[playerid][Respect]) gets values 101 and 0. I've rewritten the code for several times, same results. He're are some codes to look into
PHP код:
public OnPlayerConnect(playerid)
{
    new 
clean[PlayerInfo]; Playa[playerid] = clean;
    
Playa[playerid][Vehicle] = -1;    Playa[playerid][Level] = 1Playa[playerid][Respect] = 1;
    
String[0] = '\0';
    
format(String128"{FFFFFF}Welcome, {FF0000}%s{FFFFFF}!\nPlease select your language wich you will use to play on this server"SendName(playerid));
    
ShowPlayerDialog(playeridAccDDIALOG_STYLE_MSGBOX"Language"String"Romana""English");
    return 
1;

PHP код:
        case AccD//Language
        
{
            if(
response)
            {
                
Playa[playerid][Language] = 1msQuery[0] = '\0';
                
mysql_format(VelocitymsQuery256"SELECT * FROM `accounts` WHERE `Name` = '%s' LIMIT 1"SendName(playerid));
                
mysql_tquery(VelocitymsQuery"CheckPlayerLogin""d"playerid);
            }
            else
            {
                
Playa[playerid][Language] = 0msQuery[0] = '\0';
                
mysql_format(VelocitymsQuery256"SELECT * FROM `accounts` WHERE `Name` = '%s' LIMIT 1"SendName(playerid));
                
mysql_tquery(VelocitymsQuery"CheckPlayerLogin""d"playerid);
            } 
Here's checking password and things, now loadings:
PHP код:
    Playa[playerid][Respect]    =        cache_get_field_content_int(0,  "Respect",  Velocity);
    [
17:45:50 05/08/18] [DEBUGcache_get_field_content_int row0field_name"Respect"connection1
    
[17:45:50 05/08/18] [DEBUGCMySQLResult::GetRowDataByName row'0'field"Respect"data"1"
    
Playa[playerid][Level]        =        cache_get_field_content_int(0,  "Level",       Velocity);
    [
17:45:50 05/08/18] [DEBUGcache_get_field_content_int row0field_name"Level"connection1
    
[17:45:50 05/08/18] [DEBUGCMySQLResult::GetRowDataByName row'0'field"Level"data"1" 
The loadings are correct but when it shows me the variable result in server, it gets value 101.

Firstly, i thought there should be a format problem
PHP код:
                format(String2150"{FFFFFF}Level: {00FF00}%d\n"Playa[playerid][Level]);
                
strcat(StringString2);
                
format(String2150"{FFFFFF}Respect Points: {00FF00}%d{FFFFFF}/{00FF00}%d\n\n"Playa[playerid][Respect], Playa[playerid][Level] * 3);
                
strcat(StringString2);
                
strcat(String"{FFFFFF}For more statistics, use {FF0000}/stats{FFFFFF}.\n\n"); 
but i've put under comments the code and same thing hapenned when i checked the database.


Re: Everytime a player logins, these 2 variables changes to a fixed value - GTLS - 14.05.2018

Whats the data getting saved inside DB?


Re: Everytime a player logins, these 2 variables changes to a fixed value - cristiifrim - 14.05.2018

Quote:
Originally Posted by GTLS
Посмотреть сообщение
Whats the data getting saved inside DB?
PHP код:
        msQuery[0] = '\0'; new hmsTotalGameTime(playeridhms);
        
//----------------------------------------------------------------------
        
mysql_format(VelocitymsQuery2048"UPDATE `accounts` SET `Level` = '%d', `Respect` = '%d', `Admin` = '%d', `VIP` = '%d', `Hours` = '%d', `Minutes` = '%d', `Coins` = '%d',\
         `Money` = '%d', `Score` = '%d', `Day` = '%d', `Month` = '%d', `Year` = '%d' WHERE `ID` = '%d'"
,
        
Playa[playerid][Level], Playa[playerid][Respect], Playa[playerid][Admin], Playa[playerid][Vip], hmPlaya[playerid][Coins],
          
GetPlayerMoney(playerid), GetPlayerScore(playerid), Playa[playerid][Day], Playa[playerid][Month], Playa[playerid][Year], Playa[playerid][ID][1]);
        
mysql_pquery(VelocitymsQuery); 



Re: Everytime a player logins, these 2 variables changes to a fixed value - CodeStyle175 - 14.05.2018

mysql_format you don't need to use this, when you dont update string value


Re: Everytime a player logins, these 2 variables changes to a fixed value - cristiifrim - 14.05.2018

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
mysql_format you don't need to use this, when you dont update string value
Saving isn't a problem, it saves correctly with bot, format and mysql_format. After the load, these 2 variables, Playa[playerid][Level] and Playa[playerid][Respect] get values 101 and 0, on every testing account.