Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

mysql error. [save, and load ]

$
0
0
Hello!!It does not save the data and loads it.

MY Plugin: MYSQL R41-2.

if you fix it I would thank you very much

Please Help, thank you!!



Code:

DIALOG(DIALOG_LOGIN_PASSWORD)
{
        if(!response) return ShowLoginDialog(playerid,PHASE_USERNAME);
        if(isnull(inputtext)) return ShowLoginDialog(playerid,PHASE_PASSWORD);
        format(query,sizeof(query),"SELECT * FROM players WHERE Name = '%s' AND Password = MD5('%s')",pName(playerid),inputtext);
        new escape[128]; mysql_escape_string(query,escape);
        mysql_query(SQL,query);
        if(!cache_num_rows())
        {
                Player_PasswordTries[playerid]++;
                new string[128]; format(string,sizeof(string),"Wrong Password! [%d/%d]",Player_PasswordTries[playerid],MAX_PASSWORD_TRIES);
                ERR(playerid,string);
                if(Player_PasswordTries[playerid] >= MAX_PASSWORD_TRIES) return KickEx(playerid);
                ShowLoginDialog(playerid,PHASE_PASSWORD);
        }
        else
        {
        mysql_format(SQL, query, sizeof(query), "SELECT * FROM `players` WHERE `Name` = '%e' LIMIT 1", pName(playerid));
        mysql_tquery(SQL, query, "PlayerLoad", "i", playerid);
                new logdate[64];
                cache_get_value_name(0,"LogDate",logdate,sizeof(logdate));

                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                        if(!OnlineCheck(i)) continue;
                        if(GetPlayerALevel(i) <= 0) continue;
                        MSGF(i,""COL_GREY"[ID:%d] %s joined the server",playerid,pName(playerid,true));
                }
               
                // [ Player Load ]
               

               
                MSGF(playerid,""COL_GREEN"(( Welcome Server. Last Login %s ))",logdate);
                TogglePlayerSpectating(playerid,false);
                PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                SetPlayerVirtualWorld(playerid,0);
                StopAudioStreamForPlayer(playerid);
                SpawnPlayer(playerid);
        }
        return 1;

}

Code:

forward PlayerLoad(playerid);
public PlayerLoad(playerid)
{
    cache_get_value_name_float(0, "PosX", pInfo[playerid][PosX]);
    cache_get_value_name_float(0, "PosY", pInfo[playerid][PosY]);
    cache_get_value_name_float(0, "PosZ", pInfo[playerid][PosZ]);
    cache_get_value_name_float(0, "JatekosHP", pInfo[playerid][JatekosHP]);
    cache_get_value_name_float(0, "JatekosPancel", pInfo[playerid][JatekosPancel]);
    cache_get_value_name_float(0, "JatekosAngle", pInfo[playerid][JatekosAngle]);
    cache_get_value_name_int(0, "JatekosPancel", pInfo[playerid][pJatekosPenz]);
    cache_get_value_name_int(0, "JatekosSzint", pInfo[playerid][pJatekosSzint]);
    cache_get_value_name_int(0, "Admin", pInfo[playerid][pAdmin]);
    cache_get_value_name_int(0, "JatekosOra", pInfo[playerid][pJatekosOra]);
    cache_get_value_name_int(0, "JatekosPerc", pInfo[playerid][pJatekosPerc]);
    cache_get_value_name_int(0, "JatekosMPerc", pInfo[playerid][pJatekosMPerc]);
    cache_get_value_name_int(0, "JatekosOles", pInfo[playerid][pJatekosOles]);
    cache_get_value_name_int(0, "JatekosInti", pInfo[playerid][pJatekosInti]);
    cache_get_value_name_int(0, "JatekosHalal", pInfo[playerid][pJatekosHalal]);
    cache_get_value_name_int(0, "JatekosSkin", pInfo[playerid][pJatekosSkin]);

    return true;
}

ONPLAYERDISC
Code:

public OnPlayerDisconnect(playerid, reason)
{
        if(!OnlineCheck(playerid)) return ResetPlayerVariables(playerid,0);
        new reasons[3][32] = {"FAGY/Crash","Kilépett","Kick/Ban"};
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                if(!OnlineCheck(i)) continue;
                if(GetPlayerALevel(i) <= 0) continue;
                MSGF(i,""COL_GREY"[ID:%d] %s left server (Reson: %s)",playerid,pName(playerid,true),reasons[reason]);
        }
        KillTimer(oratimer[playerid]);
        SavePlayer(playerid);
        return 1;
}

SAVEPLAYER:
Code:

stock SavePlayer(playerid)
{

                format(query,sizeof(query),"UPDATE `PLAYERS` SET LogDate = '%s', Admin = %d, JatekosPenz = %d, JatekosSzint = %d, PosX = %f, PosY = %f, PosZ = %f, JatekosInti = %d, JatekosOles = %d, JatekosHalal = %d, JatekosOra = %d, JatekosPerc = %d, JatekosMPerc = %d, JatekosSkin = %d, JatekosHP = %f JatekosPancel = %f, JatekosAngle = %f, WHERE `ID` = %d LIMIT 1",
                GetFormatedDate(),
                pInfo[playerid][pAdmin],
                pInfo[playerid][pJatekosPenz],
                pInfo[playerid][pJatekosSzint],
                pInfo[playerid][PosX],
                pInfo[playerid][PosY],
                pInfo[playerid][PosZ],
                pInfo[playerid][pJatekosInti],
                pInfo[playerid][pJatekosOles],
                pInfo[playerid][pJatekosHalal],
                pInfo[playerid][pJatekosOra],
                pInfo[playerid][pJatekosPerc],
                pInfo[playerid][pJatekosMPerc],
                pInfo[playerid][pJatekosSkin],
                pInfo[playerid][JatekosHP],
                pInfo[playerid][JatekosPancel],
                pInfo[playerid][JatekosAngle],
                pInfo[playerid][pID]);
                mysql_tquery(SQL, query);
                // Reset Enums későbbiekben.
                ResetPlayerVariables(playerid,1);
                return 1;
}


Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>