SA-MP Forums Archive
Skin Keeps Changing To CJ?? - 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: Skin Keeps Changing To CJ?? (/showthread.php?tid=603336)



Skin Keeps Changing To CJ?? - Markus_Whiteus - 21.03.2016

Got quite a strange bug on my hands the players skin will set then quickly change to CJ upon spawning unless the player typed their password in incorrectly before logging in... I'm totally stumped here is the relevant code can anyone see any issues?

Login:
Код:
case dialogThreadLogin:
		{
			if(!response)
            {
                Kick(playerid);
            }
			if(response)
			{
				new query[256], EncryptedPass[130];
				
				WP_Hash(EncryptedPass, sizeof(EncryptedPass), inputtext);
				format(query, sizeof(query), "SELECT * FROM players WHERE pName = '%s' AND pPassword = '%s'", GetName(playerid), EncryptedPass);
				mysql_query(query);
				mysql_store_result();
				if(mysql_num_rows() > 0)
				{
					SendClientMessage(playerid, -1, "Logging in");
					LoginPlayer(playerid);
				}
				else
				{
					SendClientMessage(playerid, -1, "Incorrect Password!");
					ShowPlayerDialog(playerid, dialogThreadLogin, DIALOG_STYLE_INPUT, "Login", "Please login with the password you made", "Login", "Cancel");
				}
			}
		}
LoginPlayer():
Код:
stock LoginPlayer(playerid)
{
	new Float: Heal, Float: Arm,query[500], string[200];
	format(query, sizeof(query), "SELECT * FROM players WHERE pName = '%s'", GetName(playerid));
	mysql_query(query);
	mysql_store_result();
	while(mysql_fetch_row_format(query,"|"))
	{
		mysql_fetch_field_row(string, "pid"); Player[playerid][pID] = strval(string);
		mysql_fetch_field_row(Player[playerid][pName], "pName");
		mysql_fetch_field_row(Player[playerid][pPassword], "pPassword");
		mysql_fetch_field_row(string, "pAdminLevel"); Player[playerid][pAdminLevel] = strval(string);
		mysql_fetch_field_row(string, "pPlayerPos"); sscanf(string, "fff", Player[playerid][pPosition][0], Player[playerid][pPosition][1], Player[playerid][pPosition][2]);
		mysql_fetch_field_row(string, "pSkin"); Player[playerid][pSkin] = strval(string);
		mysql_fetch_field_row(string, "pMoney"); Player[playerid][pMoney] = strval(string);
		mysql_fetch_field_row(string, "pSavings"); Player[playerid][pSavings] = strval(string);
		mysql_fetch_field_row(string, "pPayCheck"); Player[playerid][pPayCheck] = strval(string);
		mysql_fetch_field_row(string, "pBank"); Player[playerid][pBank] = strval(string);
		mysql_fetch_field_row(string, "pBusiness"); Player[playerid][pBusiness] = strval(string);
		mysql_fetch_field_row(string, "pHealth"); Heal = floatstr(string);
		floatround(Heal, floatround_round);
		mysql_fetch_field_row(string, "pArmour"); Arm = floatstr(string);
		floatround(Arm, floatround_round);
		Player[playerid][pHealth] = Heal;
		Player[playerid][pArmour] = Arm;
		mysql_fetch_field_row(string, "pVip"); Player[playerid][pvStatus] = strval(string);
		mysql_fetch_field_row(string, "pMuted"); Player[playerid][pMuted] = strval(string);
		mysql_fetch_field_row(string, "pWarnings"); Player[playerid][pWarnings] = strval(string);
		mysql_fetch_field_row(string, "pWarningReasons"); sscanf(string, "p<|>s[126]s[126]s[126]", Player[playerid][pWarningReason1], Player[playerid][pWarningReason2], Player[playerid][pWarningReason3]);
		mysql_fetch_field_row(string, "pMins"); Player[playerid][pMins] = strval(string);
		mysql_fetch_field_row(string, "pHours"); Player[playerid][pHours] = strval(string);
		mysql_fetch_field_row(string, "pHouse"); Player[playerid][pHouse] = strval(string);
	}
	mysql_free_result();

	
	SetSpawnInfo(playerid, 0, Player[playerid][pSkin], Player[playerid][pPosition][0], Player[playerid][pPosition][1], Player[playerid][pPosition][2], 90, 0, 0, 0, 0, 0, 0);
	SetPlayerPos(playerid, Player[playerid][pPosition][0], Player[playerid][pPosition][1], Player[playerid][pPosition][2]);
	SetCameraBehindPlayer(playerid);
	SetPlayerHealth(playerid, Player[playerid][pHealth]);
	SetPlayerArmour(playerid, Player[playerid][pArmour]);
	SetPlayerInterior(playerid, 0);
	SetPlayerVirtualWorld(playerid, 0);
	GivePlayerMoney(playerid, Player[playerid][pMoney]);
	loadplayercars(playerid);
	SpawnPlayer(playerid);
	printf("%d",Player[playerid][pSkin]);
}
I know the skin is infact setting to the correct skin first as I have outputted Player[playerid][pSkin] and also you can see the correct on the player just as they spawn in a split second before it turns to CJ.

Many thanks in advance.
Markus


Re: Skin Keeps Changing To CJ?? - Markus_Whiteus - 22.03.2016

Bump also tried putting a
SetPlayerSkin in after player spawns still CJ


Re: Skin Keeps Changing To CJ?? - Threshold - 22.03.2016

SetSpawnInfo. Take a closer look.


Re: Skin Keeps Changing To CJ?? - Markus_Whiteus - 22.03.2016

Quote:
Originally Posted by Threshold
Посмотреть сообщение
SetSpawnInfo. Take a closer look.
Yes what about it?
Код:
(playerid, team, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
Thats the parameters shown on the wiki which fits with mine?


Re: Skin Keeps Changing To CJ?? - Threshold - 22.03.2016

Wait, what does the console print 'pSkin' as?


Re: Skin Keeps Changing To CJ?? - Markus_Whiteus - 22.03.2016

It prints out the correct ID as saved in the database in this case 245


Re: Skin Keeps Changing To CJ?? - kelvinis - 22.03.2016

Replace this
PHP код:
        SpawnPlayer(playerid); 
Into this:
PHP код:
        SpawnPlayer(playerid);
        
SetPlayerSkin(playerid277); 
Sorry for double post


Re: Skin Keeps Changing To CJ?? - kelvinis - 22.03.2016

Replace this
PHP код:
        SpawnPlayer(playerid); 
Into this:
PHP код:
        SpawnPlayer(playerid);
        
SetPlayerSkin(playeridpSkin); 
EDIT: Posted too fast


Re: Skin Keeps Changing To CJ?? - Markus_Whiteus - 22.03.2016

Quote:
Originally Posted by kelvinis
Посмотреть сообщение
Replace this
PHP код:
        SpawnPlayer(playerid); 
Into this:
PHP код:
        SpawnPlayer(playerid);
        
SetPlayerSkin(playeridpSkin); 
EDIT: Posted too fast
Still stays as CJ unless you input your password incorrectly first time, truly stumped by this bug


Re: Skin Keeps Changing To CJ?? - SyS - 23.03.2016

Quote:
Originally Posted by Markus_Whiteus
Посмотреть сообщение
Still stays as CJ unless you input your password incorrectly first time, truly stumped by this bug
Код:
public OnPlayerSpawn(playerid)
{
SetPlayerSkin( playerid, pSkin );
return 1;
}
or add SetPlayerSkin( playerid, pSkin ); this in onplayerspawn