Jump to content
  • 0

Problema MySQL Admin


BoBBiTa

Question

Problema intalnita (descriere): Salutare, am facut un sistem de admin pe MySQL, direct in GameMode. Bineinteles, am facut si o comanda ce seteaza Level de admin la player. Problema este ca dupa ce player-ul se deconecteaza, nivelul de admin nu se salveaza in baza de date.
Ero(area / rile) / warning-(ul / urile): Nu se salveaza admin level-ul in Baza de date.
Liniile de cod / sursa / script-ul(obligatoriu): 

//=========================FUNCTIA DE UPDATARE A DATELOR IN MYSQL========================//
SavePlayer(playerid)
{
	if(P_Data[playerid][pLogged] == 0)return 1;
	new query[128];
	format(query, sizeof(query), "UPDATE conturi SET Admin='%i' WHERE ID='%i'",P_Data[playerid][pAdmin], P_Data[playerid][pID]);
	mysql_function_query(handle,query,false,"","");
	return 1;
}

//===================COMANDA /SETLEVEL ==========================================//
CMD:setlevel(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))return SCM(playerid, -1, "{FF0000}BGR-Security: {FFFFFF}Nu esti admin RCON.");
	new level, UserID, query[200], szString[500], uName[MAX_PLAYER_NAME];
	if(sscanf(params, "ui",UserID, level))return SCM(playerid, -1, "{FF0000}BGR-System: {FFFFFF}Foloseste /setlevel [ playerid ] [ level 1 - 3]");
	if(level < 0 || level > 3)return SCM(playerid, -1, "{FF0000}BGR-System: {FFFFFF}Nivelul trebuie cuprins intre 1 - 3");
	format(query, sizeof(query),"UPDATE 'conturi' SET 'Admin'='%d' WHERE 'ID'='%d' LIMIT 1",level, P_Data[UserID][pID]);
	mysql_query(handle,query);
	P_Data[UserID][pAdmin] = level;
	SavePlayer(UserID);
	GetPlayerName(UserID, uName, sizeof(uName));
	format(szString, sizeof(szString), "{FF0000}BGR-System: {FFFFFF}Adminul {C0FF00}%s {FFFFFF}a setat lui {C0FF00}%s {FFFFFF}admin level %i",GetName(playerid),uName,level);
	GameTextForPlayer(playerid, "~y~Promovat.",3000,3);
	SCMALL(-1, szString);
	PlayerPlaySound(UserID,1057,0.0,0.0,0.0);
	return 1;
}
// =============FUNCTIA De La OnLogin ================================================
P_Data[playerid][pAdmin] = cache_get_field_content_int(0, "Admin",handle);

Mentionez, ca am pus SavePlayer(playerid); si la callback-ul OnPlayerDissconect..

Alta treaba ar fi ca adminul functioneaza, dar dupa deconectarea de pe server nu mai merge si trebuie folosita iarasi comanda /setlevel.
Imagini / Video (optional):
Ati incercat sa rezolvati singur?:  Am incercat sa modific pe la functia SavePlayer, sa umblu la query, sa-l fac mai mare dar tot acelasi rezultat.

// Desenul meu animat 
// Alte episoade aici: 
https://www.youtube.com/channel/UCF2kY1CzhHI_PCyV5LprQ1w/videos

 

 

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

sterge tot si pune asa:


//===================COMANDA /SETLEVEL ==========================================//
CMD:setlevel(playerid, params[])
{
    new level, UserID, query[200], szString[500], uName[MAX_PLAYER_NAME];
    
    if(!IsPlayerAdmin(playerid))
            return SCM(playerid, -1, "{FF0000}BGR-Security: {FFFFFF}Nu esti admin RCON.");
        
    if(sscanf(params, "ui",UserID, level))
            return SCM(playerid, -1, "{FF0000}BGR-System: {FFFFFF}Foloseste /setlevel [ playerid ] [ level 1 - 3]");
    
    if(level < 0 || level > 3)
            return SCM(playerid, -1, "{FF0000}BGR-System: {FFFFFF}Nivelul trebuie cuprins intre 1 - 3");
    
    format(query, sizeof(query),"UPDATE `conturi` SET `Admin`='%d' WHERE `ID`='%i'",level , P_Data[UserID][pID]);
    mysql_query(handle,query);
    
    P_Data[UserID][pAdmin] = level;
    
    SavePlayer(UserID);
    GetPlayerName(UserID, uName, sizeof(uName));
    
    format(szString, sizeof(szString), "{FF0000}BGR-System: {FFFFFF}Adminul {C0FF00}%s {FFFFFF}a setat lui {C0FF00}%s {FFFFFF}admin level %i",GetName(playerid),uName,level);
    
    GameTextForPlayer(playerid, "~y~Promovat.",3000,3);
    SCMALL(-1, szString);
    PlayerPlaySound(UserID,1057,0.0,0.0,0.0);
    return 1;
}
// =============FUNCTIA De La OnLogin ================================================
P_Data[playerid][pAdmin] = cache_get_field_content_int(0, "Admin");


Link to comment
Share on other sites

  • 0
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.