Necesito que me digan si esta bien
#1

Bueno, lo unico que se me ocurrio para guardar los datos del pj (mysql). No me da errores pero si alguno de ust con mas experiencia que yo me podria decir si esta bien o no me vendria muyy bien =D.
pawn Код:
forward SavePlayer(playerid);
public SavePlayer(playerid)
{
    if(!PlayerLogged[playerid])
        return 0;

        PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);


    CheckMySQL();

        new string[256];
        format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s'", PlayerInfo[playerid][pName]);
        mysql_query(string);
       
// lo que guarda
       
format(string, sizeof(string), "UPDATE Users SET pKey='%s'",PlayerInfo[playerid][pKey]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLevel='%s'",PlayerInfo[playerid][pLevel]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAdmin='%s'",PlayerInfo[playerid][pAdmin]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pDonateRank='%s'",PlayerInfo[playerid][pDonateRank]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET gPupgrade='%s'",PlayerInfo[playerid][gPupgrade]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pConnectTime='%s'",PlayerInfo[playerid][pConnectTime]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pReg='%s'",PlayerInfo[playerid][pReg]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pSex='%s'",PlayerInfo[playerid][pSex]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAge='%s'",PlayerInfo[playerid][pAge]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pOrigin='%s'",PlayerInfo[playerid][pOrigin]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCK='%s'",PlayerInfo[playerid][pCK]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMuted='%s'",PlayerInfo[playerid][pMuted]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pExp='%s'",PlayerInfo[playerid][pExp]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCash='%s'",PlayerInfo[playerid][pCash]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAccount='%s'",PlayerInfo[playerid][pAccount]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCrimes='%s'",PlayerInfo[playerid][pCrimes]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pKills='%s'",PlayerInfo[playerid][pKills]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pDeaths='%s'",PlayerInfo[playerid][pDeaths]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pArrested='%s'",PlayerInfo[playerid][pArrested]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pWantedDeaths='%s'",PlayerInfo[playerid][pWantedDeaths]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPhoneBook='%s'",PlayerInfo[playerid][pPhoneBook]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLottoNr='%s'",PlayerInfo[playerid][pLottoNr]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pFishes='%s'",PlayerInfo[playerid][pFishes]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pBiggestFish='%s'",PlayerInfo[playerid][pBiggestFish]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pJob='%s'",PlayerInfo[playerid][pJob]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPayCheck='%s'",PlayerInfo[playerid][pPayCheck]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pHeadValue='%s'",PlayerInfo[playerid][pHeadValue]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pJailed='%s'",PlayerInfo[playerid][pJailed]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pJailTime='%s'",PlayerInfo[playerid][pJailTime]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMats='%s'",PlayerInfo[playerid][pMats]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pDrugs='%s'",PlayerInfo[playerid][pDrugs]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLeader='%s'",PlayerInfo[playerid][pLeader]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMember='%s'",PlayerInfo[playerid][pMember]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pFMember='%s'",PlayerInfo[playerid][pFMember]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pRank='%s'",PlayerInfo[playerid][pRank]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pChar='%s'",PlayerInfo[playerid][pChar]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pContractTime='%s'",PlayerInfo[playerid][pContractTime]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pDetSkill='%s'",PlayerInfo[playerid][pDetSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pSexSkill='%s'",PlayerInfo[playerid][pSexSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pBoxSkill='%s'",PlayerInfo[playerid][pBoxSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLawSkill='%s'",PlayerInfo[playerid][pLawSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMechSkill='%s'",PlayerInfo[playerid][pMechSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pJackSkill='%s'",PlayerInfo[playerid][pJackSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCarSkill='%s'",PlayerInfo[playerid][pCarSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pNewsSkill='%s'",PlayerInfo[playerid][pNewsSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pDrugsSkill='%s'",PlayerInfo[playerid][pDrugsSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCookSkill='%s'",PlayerInfo[playerid][pCookSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pFishSkill='%s'",PlayerInfo[playerid][pFishSkill]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pHealth='%s'",PlayerInfo[playerid][pHealth]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pSHealth='%s'",PlayerInfo[playerid][pSHealth]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pInt='%s'",PlayerInfo[playerid][pInt]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLocal='%s'",PlayerInfo[playerid][pLocal]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pTeam='%s'",PlayerInfo[playerid][pTeam]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pModel='%s'",PlayerInfo[playerid][pModel]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPnumber='%s'",PlayerInfo[playerid][pPnumber]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPhousekey='%s'",PlayerInfo[playerid][pPhousekey]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPcarkey='%s'",PlayerInfo[playerid][pPcarkey]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPcarkey2='%s'",PlayerInfo[playerid][pPcarkey2]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPcarkey3='%s'",PlayerInfo[playerid][pPcarkey3]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pGangKey='%s'",PlayerInfo[playerid][pGangKey]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPbiskey='%s'",PlayerInfo[playerid][pPbiskey]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPos_x='%s'",PlayerInfo[playerid][pPos_x]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPos_y='%s'",PlayerInfo[playerid][pPos_y]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPos_z='%s'",PlayerInfo[playerid][pPos_z]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCarLic='%s'",PlayerInfo[playerid][pCarLic]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pFlyLic='%s'",PlayerInfo[playerid][pFlyLic]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pBoatLic='%s'",PlayerInfo[playerid][pBoatLic]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pFishLic='%s'",PlayerInfo[playerid][pFishLic]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pGunLic='%s'",PlayerInfo[playerid][pGunLic]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pGun1='%s'",PlayerInfo[playerid][pGun1]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pGun2='%s'",PlayerInfo[playerid][pGun2]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pGun3='%s'",PlayerInfo[playerid][pGun3]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pGun4='%s'",PlayerInfo[playerid][pGun4]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAmmo1='%s'",PlayerInfo[playerid][pAmmo1]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAmmo2='%s'",PlayerInfo[playerid][pAmmo2]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAmmo3='%s'",PlayerInfo[playerid][pAmmo3]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAmmo4='%s'",PlayerInfo[playerid][pAmmo4]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCarTime='%s'",PlayerInfo[playerid][pCarTime]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPayDay='%s'",PlayerInfo[playerid][pPayDay]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPayDayHad='%s'",PlayerInfo[playerid][pPayDayHad]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pWatch='%s'",PlayerInfo[playerid][pWatch]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCrashed='%s'",PlayerInfo[playerid][pCrashed]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pWins='%s'",PlayerInfo[playerid][pWins]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLoses='%s'",PlayerInfo[playerid][pLoses]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pAlcoholPerk='%s'",PlayerInfo[playerid][pAlcoholPerk]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pDrugPerk='%s'",PlayerInfo[playerid][pDrugPerk]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMiserPerk='%s'",PlayerInfo[playerid][pMiserPerk]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPainPerk='%s'",PlayerInfo[playerid][pPainPerk]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pTraderPerk='%s'",PlayerInfo[playerid][pTraderPerk]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pTut='%s'",PlayerInfo[playerid][pTut]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMissionNr='%s'",PlayerInfo[playerid][pMissionNr]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pWarns='%s'",PlayerInfo[playerid][pWarns]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pVirWorld='%s'",PlayerInfo[playerid][pVirWorld]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pFuel='%s'",PlayerInfo[playerid][pFuel]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMarried='%s'",PlayerInfo[playerid][pMarried]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMarriedTo='%s'",PlayerInfo[playerid][pMarriedTo]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pFishTool='%s'",PlayerInfo[playerid][pFishTool]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pInvWeapon='%s'",PlayerInfo[playerid][pInvWeapon]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pInvAmmo='%s'",PlayerInfo[playerid][pInvAmmo]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLighter='%s'",PlayerInfo[playerid][pLighter]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCigarettes='%s'",PlayerInfo[playerid][pCigarettes]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pRequestingBackup='%s'",PlayerInfo[playerid][pRequestingBackup]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pRoadblock='%s'",PlayerInfo[playerid][pRoadblock]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMask='%s'",PlayerInfo[playerid][pMask]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pBomba='%s'",PlayerInfo[playerid][pBomba]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pMaskuse='%s'",PlayerInfo[playerid][pMaskuse]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pHideNumber='%s'",PlayerInfo[playerid][pHideNumber]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pSpeaker='%s'",PlayerInfo[playerid][pSpeaker]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLocked='%s'",PlayerInfo[playerid][pLocked]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pGPS='%s'",PlayerInfo[playerid][pGPS]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pCasco='%s'",PlayerInfo[playerid][pCasco]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLente='%s'",PlayerInfo[playerid][pLente]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLlaveP1='%s'",PlayerInfo[playerid][pLlaveP1]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLlaveP2='%s'",PlayerInfo[playerid][pLlaveP2]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pLlaveP3='%s'",PlayerInfo[playerid][pLlaveP3]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pPuntosL='%s'",PlayerInfo[playerid][pPuntosL]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pRelojM='%s'",PlayerInfo[playerid][pRelojM]);
mysql_query(string);
format(string, sizeof(string), "UPDATE Users SET pSueldo='%s'",PlayerInfo[playerid][pSueldo]);
mysql_query(string);
return 1;
}
No estoy seguro si los datos se guardaran en el campo correcto =S

Ahh me olvidaba, ya se que todos los %s estan mal xD, pero no quiero hacer todo y si esta mal tener que volverlo a hacer.
Reply
#2

Y por quй no usas una tabla para cada jugador?, estoy leyendo sobre mysql, y por lo que veo usas la misma tabla, solo guardas en columnas Xd
Reply
#3

Esta bien, aun asн te recomiendo que uses el callback OnQueryFinish, ya que con esto las query se ejecutan en segundo plano, son mas rбpidas y no afectas el rendimiento del servidor.

https://sampwiki.blast.hk/wiki/MySQL#OnQueryFinish

Asimismo, puedes usar mysql_format para darle formato a las querys en vez de format, ahн tambiйn puedes escapar algunos caracteres al mismo tiempo.

https://sampwiki.blast.hk/wiki/MySQL#mysql_format

Note que tienes una funciуn CheckMySQL() imagino que es para hacer ping a la base de datos, usando OnQueryFinish no es necesario, ya que realiza re conexiones automбticamente.

https://sampwiki.blast.hk/wiki/MySQL#mysql_ping

Quote:
Important Note: Connection state check (and reconnect if needed) happens automatically incase you are using threaded callback, so you don't need to perform any manual checks.

Saludos!
Reply
#4

Muchass graciass =D, ya me estoy estudiando todas esas funciones! rep++
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)