SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/12/2014, 06:39 PM   #1
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,240
Reputation: 54
Default skin help - always spawn as cj skin

Hi. i'm having problem with this skin spawning as cj. Every time I choose different skin under request class, it always spawn as CJ Skin. Now, the /skin command is working fine, it shows the skin I want. Also after checking my user database I can see that the skin value has changed.

So what I did next was I tried to exit game to see if the skin will save or not. And yes, the value of skin from user database were still the same.

Then going back to ingame after logging in successfully and hitting spawn button. Again it spawns as Cj skin.

Where could be the problem?
__________________
kbalor is offline   Reply With Quote
Old 08/12/2014, 06:46 PM   #2
HY
Gangsta
 
HY's Avatar
 
Join Date: Sep 2014
Location: România.
Posts: 540
Reputation: 87
Default Re: skin help - always spawn as cj skin

pawn Code:
#define PATH "/Skins/%s.ini"

//Enums
enum sInfo
{
    Skin
}
new SkinInfo[MAX_PLAYERS][sInfo];

forward LoadUser_data(playerid,name[],value[]);

public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Skin",SkinInfo[playerid][Skinl]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Skin",SkinInfo[playerid][Skin]);
    INI_Close(File);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Skin",0);
    INI_Close(File);
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerSkin(playerid, SkinInfo[playerid][Skin]);
    return 1;
}


stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
__________________
hi.
HY is offline   Reply With Quote
Old 08/12/2014, 06:48 PM   #3
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,240
Reputation: 54
Default Re: skin help - always spawn as cj skin

Quote:
Originally Posted by HY View Post
pawn Code:
#define PATH "/Skins/%s.ini"

//Enums
enum sInfo
{
    Skin
}
new SkinInfo[MAX_PLAYERS][sInfo];

forward LoadUser_data(playerid,name[],value[]);

public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Skin",SkinInfo[playerid][Skinl]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Skin",SkinInfo[playerid][Skin]);
    INI_Close(File);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Skin",0);
    INI_Close(File);
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerSkin(playerid, SkinInfo[playerid][Skin]);
    return 1;
}


stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
Hi dear, thanks for the help but I already have mysql saving system it is better. and I wanted to know why and where I can find the problem.

EDIT: Well after trying so hard to figure out why it turns to Cj skin. I found that the skin value change to 0 under onplayerconnect. Can you please help me with this?
__________________

Last edited by kbalor; 08/12/2014 at 07:29 PM.
kbalor is offline   Reply With Quote
Old 08/12/2014, 07:32 PM   #4
Cypress
Gangsta
 
Cypress's Avatar
 
Join Date: Dec 2009
Location: Germany
Posts: 938
Reputation: 127
Default Re: skin help - always spawn as cj skin

The problem could be when you spawn the player after he enters his password to log in. For example if you are using SetSpawnInfo and it's skinid is set to 0, you will be spawning with CJ skin.

You should consider showing some code if you want to get help in a proper way, else we can't be guessing what you have done wrong in your code.
Cypress is offline   Reply With Quote
Old 08/12/2014, 07:49 PM   #5
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,240
Reputation: 54
Default Re: skin help - always spawn as cj skin

Quote:
Originally Posted by Cypress View Post
The problem could be when you spawn the player after he enters his password to log in. For example if you are using SetSpawnInfo and it's skinid is set to 0, you will be spawning with CJ skin.

You should consider showing some code if you want to get help in a proper way, else we can't be guessing what you have done wrong in your code.
Hello thanks for the info regarding to this quoted "The problem could be when you spawn the player after he enters his password to log in"

Actually I found the problem and it was under onplayerconnect. So before I spawn, do any changes of my skin or log in, under onplayerconnect it has already been changed to 0, so even I logged in it will stay as skin 0. I wonder why because as you can see the value of Admin is still 6 it hasn't been change to 0. Maybe theres a problem with mysql loading database?



Code:
public OnPlayerConnect(playerid)
{
    new Query[100];
	format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `Name` = '%s'",GetName(playerid));
	mysql_function_query(cHandle, Query, true, "CheckIP", "d", playerid);
	
    new Query1[100];
	format(Query1,sizeof(Query1),"SELECT * FROM `users` WHERE `Name` = '%s'",GetName(playerid));
	mysql_function_query(cHandle, Query1, true, "CheckAccount", "d", playerid);
	
	SendClientMessageToAllEx(-1, ""WHITE"%s[%d] has joined the server!", GetName(playerid), playerid);
	SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
	
	new joinMsg[128], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(joinMsg, sizeof(joinMsg), "04***[JOIN] 01[%d] %s has joined the server.", playerid, name);
	IRC_GroupSay(groupID, IRC_CHANNEL, joinMsg);
	
	new message[128];
	format(message, sizeof(message), "04***[JOIN] 01[%d] %s has joined the server. (IP: %s)", playerid,       GetName(playerid), GetIp(playerid));
	IRC_GroupSay(groupIDA, IRC_ADMIN_CHANNEL, message);
	
	DescriptionText[playerid] = TextDrawCreate(320.0, 380.0, " ");
	TextDrawAlignment(DescriptionText[playerid], 2);
	TextDrawFont(DescriptionText[playerid], 1);
	TextDrawLetterSize(DescriptionText[playerid], 0.320000, 1.700000);
	TextDrawSetOutline(DescriptionText[playerid], 1);
	TextDrawHideForPlayer(playerid, DescriptionText[playerid]);
	
	indm[playerid] = 0;
	stunt[playerid] = 0;
	toggoto[playerid] = 0;
	togbring[playerid] = 0;
	freezed[playerid] = 0;
	blockcmds[playerid] = 0;
	muted[playerid] = 0;
	induel[playerid] = 0;
	watchduel[playerid] = 0;
	togduel[playerid] = 0;
	inviter[playerid] = 0;
	invite[playerid] = 0;
	ewatch[playerid] = 0;
	LastSender[playerid] = -1;
	DuelSender[playerid] = -1;
	hayparkourspawn[playerid] = 0;
	rwdmspawn[playerid] = 0;
	wwdmspawn[playerid] = 0;
	deagledmspawn[playerid] = 0;
	boxdmspawnok[playerid] = 0;
	builddmspawn[playerid] = 0;
	racespawnok[playerid] = 0;
	TextsActive[playerid] = 0;
	PlayerSeconds[playerid] = 0;
	inbikec[playerid] = 0;
	inbikec2[playerid] = 0;
	inbp1[playerid] = 0;
	inbp2[playerid] = 0;
	inparkour1[playerid] = 0;
	inhayparkour[playerid] = 0;
	inbikecmap[playerid] = 0;
	inbikec2map[playerid] = 0;
	inparkour[playerid] = 0;
	readpms[playerid] = 0;
	rcpoint[playerid] = -1;
	racestarted[playerid] = 0;
	EnableBoost[playerid] = 0;
	g_antifall[playerid] = false;
        g_bump[playerid] = false;
        g_veh[playerid] = -1;
	SpeedBoostMultiplier[playerid] = 1.2;
	Better[playerid] = 0;
	return 1;
}
Code:
public LoginPlayer(playerid)
{
	new rows, fields;
    cache_get_data(rows, fields, cHandle);
    if(rows)
    {
    	new mHolder[500];
      	cache_get_field_content(0, "Admin", mHolder, cHandle);
      	PlayerInfo[playerid][Admin] = strval(mHolder);

		cache_get_field_content(0, "Founder", mHolder, cHandle);
      	PlayerInfo[playerid][Founder] = strval(mHolder);

      	cache_get_field_content(0, "Score", mHolder, cHandle);
      	PlayerInfo[playerid][Score] = strval(mHolder);
      	SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
      	
      	cache_get_field_content(0, "Skin", mHolder, cHandle);
      	PlayerInfo[playerid][Skin] = strval(mHolder);
      	SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);

      	cache_get_field_content(0, "Money", mHolder, cHandle);
      	PlayerInfo[playerid][Money] = strval(mHolder);
      	GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);

      	cache_get_field_content(0, "Deaths", mHolder, cHandle);
      	PlayerInfo[playerid][Deaths] = strval(mHolder);

      	cache_get_field_content(0, "Kills", mHolder, cHandle);
      	PlayerInfo[playerid][Kills] = strval(mHolder);
      	
      	cache_get_field_content(0, "Banned", mHolder, cHandle);
      	PlayerInfo[playerid][Banned] = strval(mHolder);
      	
      	cache_get_field_content(0, "RegDate", mHolder, cHandle);
      	format(regdate, sizeof(regdate),"%s", mHolder);
      	PlayerInfo[playerid][RegDate] = strval(mHolder);
      	
		cache_get_field_content(0, "RGB", mHolder, cHandle);
      	SetPlayerColor(playerid, strval(mHolder));
      	SetPlayerColourAlpha(playerid,500);
      	
      	cache_get_field_content(0, "TextCol", mHolder, cHandle);
      	TextsActive[playerid] = strval(mHolder);
		
		cache_get_field_content(0, "God", mHolder, cHandle);
		god[playerid] = strval(mHolder);
		
		if(god[playerid] == 1)
		{
			SetPlayerHealth(playerid,99999);
		}
		if(god[playerid] == 0)
		{
			SetPlayerHealth(playerid,100);
		}
		
		cache_get_field_content(0, "GodCar", mHolder, cHandle);
		AutoRepair[playerid] = strval(mHolder);
		
		if(AutoRepair[playerid] == 1)
		{
			FixTimer = SetTimer("FixCar",1000,true);
		}
		if(AutoRepair[playerid] == 0)
		{
			KillTimer(FixTimer);
		}
      	
      	cache_get_field_content(0, "TimeOnline", mHolder, cHandle);
		PlayerInfo[playerid][TimeOnline] = strval(mHolder);
        playerOnline[playerid] = gettime();
		new Query[100];
		format(Query,sizeof(Query),"UPDATE `users` SET `IP` = '%s' WHERE `Name` = '%s'",GetIp(playerid),GetName(playerid));
		mysql_function_query(cHandle, Query, false, "", "d", playerid);
		SendClientMessageEx(playerid, -1 , ""RED"[LOGIN] "WHITE"Welcome back, %s! You are now logged in.", GetName(playerid));
		SendClientMessage(playerid, -1 , ""RED"[HELP] "WHITE"Type /cmds to access the current commands in our server!");
	}
}
MYSQL LOG
Quote:
[23:39:39] >> mysql_connect(localhost, root, test, ******) on port 3306
[23:39:39] CMySQLHandler::CMySQLHandler() - constructor called.
[23:39:39] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "tes" | Username: "root"
[23:39:39] CMySQLHandler::Connect() - Connection was successful.
[23:39:39] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[23:39:39]
[23:39:39] ** MySQL Debugging enabled (12/08/14)
[23:39:39]
[23:39:39] >> mysql_connect(localhost, root, test, ******) on port 3306
[23:39:39] CMySQLHandler::Connect() - Connection was successful.
[23:39:39] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[23:39:44] >> mysql_query_callback( Connection handle: 1 )
[23:39:44] >> mysql_query_callback( Connection handle: 1 )
[23:39:44] Passing query SELECT * FROM `users` WHERE `Name` = 'Kevs' | d
[23:39:44] ProcessQueryThread(CheckIP) - Query was successful. (SELECT * FROM `users` WHERE `Name` = 'Kevs')
[23:39:44] ProcessQueryThread(CheckIP) - Data caching enabled.
[23:39:44] CMySQLHandler::StoreResult() - Result was stored.
[23:39:44] CMySQLHandler::FreeResult() - Result was successfully free'd.
[23:39:44] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[23:39:44] CheckIP(d) - Threaded function called.
[23:39:44] >> cache_get_data( Connection handle: 1 )
[23:39:44] ProcessTick() - The cache has been cleared.
[23:39:44] Passing query SELECT * FROM `users` WHERE `Name` = 'Kevs' | d
[23:39:44] ProcessQueryThread(CheckAccount) - Query was successful. (SELECT * FROM `users` WHERE `Name` = 'Kevs')
[23:39:44] ProcessQueryThread(CheckAccount) - Data caching enabled.
[23:39:44] CMySQLHandler::StoreResult() - Result was stored.
[23:39:44] CMySQLHandler::FreeResult() - Result was successfully free'd.
[23:39:44] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[23:39:44] CheckAccount(d) - Threaded function called.
[23:39:44] >> cache_get_data( Connection handle: 1 )
[23:39:44] ProcessTick() - The cache has been cleared.
[23:39:45] >> mysql_query_callback( Connection handle: 1 )
[23:39:45] Passing query UPDATE `users` SET `Admin` = '0', `Founder` = '0', `Money` = '0', `Score` = '0', `Kills` = '0', `Deaths` = '0', `Skin` = '0', `IP` = '192.168.2.103', `TimeOnline` = '1418067585', `Days` = '16412', `Hours` = '19', `Minutes` = '39' WHERE `Name` = 'Kevs' | d
[23:39:45] ProcessQueryThread() - Query was successful. (UPDATE `users` SET `Admin` = '0', `Founder` = '0', `Money` = '0', `Score` = '0', `Kills` = '0', `Deaths` = '0', `Skin` = '0', `IP` = '192.168.2.103', `TimeOnline` = '1418067585', `Days` = '16412', `Hours` = '19', `Minutes` = '39' WHERE `Name` = 'Kevs')
[23:39:45] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[23:39:45] (d) - Threaded function called.
[23:39:46] >> mysql_query_callback( Connection handle: 1 )
[23:39:46] Passing query UPDATE `users` SET `Admin` = '0', `Founder` = '0', `Money` = '0', `Score` = '0', `Kills` = '0', `Deaths` = '0', `Skin` = '0', `IP` = '192.168.2.103', `TimeOnline` = '1418067586', `Days` = '16412', `Hours` = '19', `Minutes` = '39' WHERE `Name` = 'Kevs' | d
[23:39:46] ProcessQueryThread() - Query was successful. (UPDATE `users` SET `Admin` = '0', `Founder` = '0', `Money` = '0', `Score` = '0', `Kills` = '0', `Deaths` = '0', `Skin` = '0', `IP` = '192.168.2.103', `TimeOnline` = '1418067586', `Days` = '16412', `Hours` = '19', `Minutes` = '39' WHERE `Name` = 'Kevs')
[23:39:46] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
__________________
kbalor is offline   Reply With Quote
Old 10/12/2014, 08:23 PM   #6
Cypress
Gangsta
 
Cypress's Avatar
 
Join Date: Dec 2009
Location: Germany
Posts: 938
Reputation: 127
Default Re: skin help - always spawn as cj skin

The problem isn't under OPC callback, it's pretty normal to reset player variables once a new player joins the server unless you are loading the values to variables out of your MySQL database before actually resetting them.

What happens is that if you have class selection with CJ's skin, and you just load their skin when they log in, and wait for them to hit the spawn button, it will obviously spawn them with a CJ skin.

What you have to do and would probably be good is make an automatic spawn system using SetSpawnInfo or setting their skin under OPS button.

However, if you have class selection, you would still need to apply the SetPlayerSkin under OPS.
Cypress is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Skin por SPAWN SONEKA Português/Portuguese 1 01/05/2014 10:39 AM
Get same skin when spawn. Configuration Scripting Help 3 17/07/2013 07:26 AM
Set Skin On Spawn Anthonyx3' Help Archive 11 12/01/2011 09:30 PM
Spawn Skin InsaneESN Help Archive 4 11/06/2010 11:33 PM
Spawn car for skin Faust Help Archive 2 24/02/2009 08:10 PM


All times are GMT. The time now is 11:15 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.