SA-MP Forums Archive
Setting position only works for a certain player from MySQL - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Setting position only works for a certain player from MySQL (/showthread.php?tid=255652)



Setting position only works for a certain player from MySQL - Jochemd - 16.05.2011

Hello,

Now I got a weird problem again. It seems like my position is not setting itself at all, while it does from my normal account. Code is incuded, also the .sql file is. I hope anyone sees this problem, cause I didn't and I am searching for a hour and 30 minutes -.-"
pawn Код:
else if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            new Playername[MAX_PLAYER_NAME],string[129],Store[45],Float:FloatStore[6],StringStore[100],QueryString[128],Line[600],RealPass[129];
            GetPlayerRPName(playerid,Playername,sizeof(Playername));
            WP_Hash(string,sizeof(string),inputtext);
            if(!isnull(inputtext))
            {
                format(QueryString,sizeof(QueryString),"SELECT * FROM `PlayerInfo` WHERE `Playername` = '%s'",Playername);
                mysql_query(QueryString);
                mysql_store_result();
                if(mysql_num_rows() != 0)
                {
                    if(mysql_fetch_row(Line))
                    {
                        sscanf(Line,"p<|>s[24]s[129]ddddddddddddddddddddddds[128]s[128]s[128]s[128]s[128]s[128]s[128]s[128]s[128]s[128]dddddddfffs[30]ddfffdddddddd",Playername,RealPass,Store[0],Store[1],Store[2],Store[3],Store[4],Store[5],Store[6],Store[7],Store[8],Store[9],Store[10],Store[11],Store[12],Store[13],Store[14],Store[15],Store[16],Store[17],Store[18],Store[19],
                        Store[20],Store[21],Store[22],PlayerInfo[playerid][Document1Text],PlayerInfo[playerid][Document2Text],PlayerInfo[playerid][Document3Text],PlayerInfo[playerid][Document4Text],PlayerInfo[playerid][Document5Text],PlayerInfo[playerid][Document6Text],PlayerInfo[playerid][Document7Text],PlayerInfo[playerid][Document8Text],PlayerInfo[playerid][Document9Text],
                        PlayerInfo[playerid][Document10Text],Store[23],Store[24],Store[25],Store[26],Store[27],Store[28],Store[29],FloatStore[0],FloatStore[1],FloatStore[2],StringStore,Store[30],Store[31],FloatStore[3],FloatStore[4],FloatStore[5],Store[32],Store[33],Store[34],Store[35],Store[36],Store[37],Store[38],Store[39]);
                        if(!strcmp(RealPass,string,true))
                        {
                            SetPVarInt(playerid,"PhoneNumber",Store[0]);
                            if(GetPVarInt(playerid,"PhoneNumber") > 0) SetPVarInt(playerid,"HavingPhone",1);
                            SetPVarInt(playerid,"gTeam",Store[1]);
                            SetPVarInt(playerid,"gFamily",Store[2]);
                            SetPVarInt(playerid,"GunDealerLevel",Store[3]);
                            SetPVarInt(playerid,"IsLogged",1);
                            SetPVarInt(playerid,"DrivingLicense",Store[4]);
                            SetPVarInt(playerid,"TruckLicense",Store[5]);
                            SetPVarInt(playerid,"Phonebook",Store[6]);
                            SetPVarInt(playerid,"BankMoney",Store[7]);
                            SetPVarInt(playerid,"BankPincode",Store[39]);
                            SetPVarInt(playerid,"MedicalKits",Store[8]);
                            SetPVarInt(playerid,"Ropes",Store[9]);
                            SetPVarInt(playerid,"BlindFolds",Store[10]);
                            SetPVarInt(playerid,"ScrewDrivers",Store[11]);
                            SetPVarInt(playerid,"Laptop",Store[12]);
                            SetPVarInt(playerid,"Mats",Store[13]);
                            SetPVarInt(playerid,"IsDeath",Store[14]);
                            SetPVarInt(playerid,"PayDayTime",Store[15]);
                            SetPVarInt(playerid,"PayDayExtra",Store[16]);
                            SetPVarInt(playerid,"AdminLevel",Store[17]);
                            SetPVarInt(playerid,"IsOocMuted",Store[18]);
                            SetPVarInt(playerid,"IsAskMuted",Store[19]);
                            SetPVarInt(playerid,"VipLevel",Store[20]);
                            SetPVarInt(playerid,"Age",Store[21]);
                            SetPVarInt(playerid,"Gender",Store[22]);
                            if(GetPVarInt(playerid,"gTeam") == JOB_FISHERMAN)
                            {
                                SetPVarInt(playerid,"FishCarpers",Store[23]);
                                SetPVarInt(playerid,"FishTuna",Store[24]);
                                SetPVarInt(playerid,"FishSalmon",Store[25]);
                                SetPVarInt(playerid,"FishSole",Store[26]);
                                SetPVarInt(playerid,"FishLobster",Store[27]);
                            }
                            if(Store[28] > 0) // GrowingWeed
                            {
                                SetPVarInt(playerid,"GrowingWeed",Store[28]);
                                SetPVarInt(playerid,"WeedSeedsWatered",Store[29]);
                                SetPVarFloat(playerid,"PlantingWeedX",FloatStore[0]);
                                SetPVarFloat(playerid,"PlantingWeedY",FloatStore[1]);
                                SetPVarFloat(playerid,"PlantingWeedZ",FloatStore[2]);
                                PlayerInfo[playerid][WeedGrowTimer] = SetTimerEx("OnWeedSeedsGrow",1000,1,"i",playerid);
                            }
                            SetPVarString(playerid,"PlayerAccent",StringStore);
                            if(Store[30]) TextDrawShowForPlayer(playerid,GlobalInfo[WatchDraw]);
                            PlayerPlaySound(playerid,1186,0.0,0.0,0.0);
                            SetPlayerMapIcon(playerid,1,-1955.5568,277.8892,40.7562,55,MAPICON_LOCAL);
                            GameTextForPlayer(playerid,"~r~Resume ~w~on saved ~b~positions",3000,1);
                            SetPlayerScore(playerid,Store[31]);
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,COLOR_TURQOISE,"Use /ask if you need any help, with server-related things.");
                            SendClientMessage(playerid,-1," ");
                            SendClientMessage(playerid,-1," ");
                            if(GetPVarInt(playerid,"VipLevel") == 0) SetPlayerColor(playerid,COLOR_WHITE) && format(string,sizeof(string)," - Welcome back, %s. Time until next Paycheck: %d seconds. Your current job: %s. -",Playername,GetPVarInt(playerid,"PayDayTime"),GetJobNameFromID(GetPVarInt(playerid,"gTeam")));
                            else if(GetPVarInt(playerid,"VipLevel") == 1) SetPlayerColor(playerid,COLOR_BROWN) && format(string,sizeof(string)," - Welcome back, %s. Your Vip Level: Bronze. Time until next Paycheck: %d seconds. Your current job: %s. -",Playername,GetPVarInt(playerid,"PayDayTime"),GetJobNameFromID(GetPVarInt(playerid,"gTeam")));
                            else if(GetPVarInt(playerid,"VipLevel") == 2) SetPlayerColor(playerid,COLOR_LIGHTGREY) && format(string,sizeof(string)," - Welcome back, %s. Your Vip Level: Silver. Time until next Paycheck: %d seconds. Your current job: %s. -",Playername,GetPVarInt(playerid,"PayDayTime"),GetJobNameFromID(GetPVarInt(playerid,"gTeam")));
                            else if(GetPVarInt(playerid,"VipLevel") == 3) SetPlayerColor(playerid,COLOR_YELLOW) && format(string,sizeof(string)," - Welcome back, %s. Your Vip Level: Gold. Time until next Paycheck: %d seconds. Your current job: %s. -",Playername,GetPVarInt(playerid,"PayDayTime"),GetJobNameFromID(GetPVarInt(playerid,"gTeam")));
                            SendClientMessage(playerid,COLOR_YELLOW,string);
                            PlayerInfo[playerid][PayDayTimer] = SetTimerEx("OnPlayerPayday",1000,1,"i",playerid);
                            KillTimer(PlayerInfo[playerid][MovingCameraTimer]);
                            SetPlayerPos(playerid,FloatStore[3],FloatStore[4],FloatStore[5]);
                            SetPlayerInterior(playerid,Store[32]);
                            if(Store[32] == 1) StreamObjects(playerid);
                            SetPlayerVirtualWorld(playerid,Store[33]);
                            SetPlayerSkin(playerid,Store[34]);
                            SetPlayerFightingStyle(playerid,Store[35]);
                            SetPlayerWantedLevel(playerid,Store[36]);
                            SetPlayerCash(playerid,Store[37]);
                            SetCameraBehindPlayer(playerid);
                            SetPVarInt(playerid,"FirstConnect",0);
                            SetPlayerInHospital(playerid);
                            SetPVarInt(playerid,"JailCountDown",Store[38]);
                            if(GetPVarInt(playerid,"JailCountDown") > 0)
                            {
                                new randpos = random(5);
                                switch(randpos)
                                {
                                    case 0: SetPlayerPos(playerid,693.7203,-4412.6436,6.9868);
                                    case 1: SetPlayerPos(playerid,683.7387,-4412.4180,6.9868);
                                    case 2: SetPlayerPos(playerid,672.3016,-4414.1641,6.9868);
                                    case 3: SetPlayerPos(playerid,681.9968,-4392.6797,6.9868);
                                    case 4: SetPlayerPos(playerid,693.0054,-4392.3984,6.9868);
                                }
                                SetPlayerInterior(playerid,1);
                                SetPlayerVirtualWorld(playerid,0);
                                GameTextForPlayer(playerid,"~r~Resume ~w~in ~b~jail!",3000,1);
                                PlayerInfo[playerid][JailCountDownTimer] = SetTimerEx("OnPlayerReleaseJail",1000,1,"i",playerid);  
                            }
                        }
                        else ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,""#EMBED_WHITE"Login",""#EMBED_WHITE"Welcome back to San Francisco '90s Roleplay.\n\nYour account is registered. Please log in with your password to continue.","Login","Quit");
                    }
                }
            }
            else ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,""#EMBED_WHITE"Login",""#EMBED_WHITE"Welcome back to San Francisco '90s Roleplay.\n\nYour account is registered. Please log in with your password to continue.","Login","Quit");
        }
        else Kick(playerid);
        return 1;
    }
Please inform me straight away, I'm very frustrated.

Jochem


Re: Setting position only works for a certain player from MySQL - Raimis_R - 16.05.2011

So when you loading account all data its loading fine but only player poz not?


Re: Setting position only works for a certain player from MySQL - Jochemd - 16.05.2011

Also skin does not load.


Re: Setting position only works for a certain player from MySQL - Jochemd - 17.05.2011

I think it only works for the first line of fields in MySQL. Unsure though :S


Re: Setting position only works for a certain player from MySQL - Donya - 17.05.2011

i had this problem. i had to switch from sscanf loading to raw getting fields.. just so vars won't come out different. eg a mysql field was 23 it came out as 298 or 0 or something


Re: Setting position only works for a certain player from MySQL - Jochemd - 17.05.2011

How did you fix it?


Re: Setting position only works for a certain player from MySQL - Donya - 17.05.2011

i removed sscanf code and loaded using mysql_fetch_field for every field s:, i actually looked at performance, it was only like 2 ms off (about 102 fields)


Re: Setting position only works for a certain player from MySQL - Jochemd - 17.05.2011

I'll try that, thanks

Edit: Would be much work, there should be a simpler way?


Re: Setting position only works for a certain player from MySQL - Donya - 17.05.2011

i realize it takes up alot of lines and work, but ohwell.. that was the only fix after 2 months of trying everything..


Re: Setting position only works for a certain player from MySQL - Jochemd - 17.05.2011

Could you give an example of it?