Last used skin - 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: Last used skin (
/showthread.php?tid=590258)
Last used skin -
Hybris - 27.09.2015
Hello I have a issue with checking last used skin,I put this on player disconnect so it saves on my query
Код:
new skinid;
if(GetPlayerSkin(playerid) == skinid)
{
pInfo[playerid][Skin]+++;
}
but it doesnt get the last used skin can someone please help me?
Re: Last used skin -
J0sh... - 27.09.2015
Wat. new skinid = GetPlayerSkin(playerid);
or pInfo[playerid][Skin] = GetPlayerSkin(playerid);
query blahblahblah Skin = skinid;
What are you trying to do? Skinid is 0 because it's a new integer.
Re : Last used skin -
StreetRP - 27.09.2015
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
return 1;
}
PHP код:
public OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid, pInfo[playerid][Skin]);
return 1;
}
Re: Re : Last used skin -
Hybris - 27.09.2015
Quote:
Originally Posted by StreetRP
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
return 1;
}
PHP код:
public OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid, pInfo[playerid][Skin]);
return 1;
}
|
You're really close but I also need it to save the skinid...Which means that it needs to save the number of it
Re: Last used skin -
Stanford - 27.09.2015
Alright, under
OnPlayerDisconnect:
pawn Код:
new query[128];
PlayerSkin[playerid] = GetPlayerSkin(playerid);
mysql_format(sqlLine, query, sizeof(query), "UPDATE `players` SET `skinid`= '%d' WHERE `userID` = '%d'", PlayerSkin[playerid], UserID[playerid]);
mysql_tquery(sqlLine, query, "", "");
-
You can depend also on the playername instead of the userID in your database.
-
You can also use normal formatting (format) instead of mysql_format as you are not going to escape strings while saving the skin id.
I hope I helped any feedback is appreciated!
Re: Last used skin -
Hybris - 27.09.2015
Quote:
Originally Posted by Stanford
Alright, under OnPlayerDisconnect:
pawn Код:
new query[128]; PlayerSkin[playerid] = GetPlayerSkin(playerid); mysql_format(sqlLine, query, sizeof(query), "UPDATE `players` SET `skinid`= '%d' WHERE `userID` = '%d'", PlayerSkin[playerid], UserID[playerid]); mysql_tquery(sqlLine, query, "", "");
You can depend also on the playername instead of the userID in your database.
You can also use normal formatting (format) instead of mysql_format as you are not going to escape strings while saving the skin id.
I hope I helped any feedback is appreciated!
|
Issue is that im using buds to make my query's so when using pInfo[playerid][Skin] = something it directs it to the query itself as this is the query made already BUD::VerifyColumn("Skin", BUD::TYPE_NUMBER);
Re: Last used skin -
Stanford - 27.09.2015
Ohh so you're basically using SQLite and blazing user database?
After looking at the example provided at the thread of Slice:
pawn Код:
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
new
userid = BUD::GetNameUID( "FIRSTNAME_LASTNAME" ) // This will get the name's unique ID; it's needed to get/set information.
;
if ( userid != BUD::INVALID_UID )
{
BUD::MultiSet( userid, "i", // integer
"skinid", pInfo[playerid][Skin],
);
}
I think that this will do the job, any feedback is appreciated!
Re: Last used skin -
Hybris - 27.09.2015
I've already done that but it doesn't save the skin onto the query when the player exits im guessing that some kind of number ident needs to be added onto this line
Код:
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
I only need it to get the skin id and set it onto the query when the player disconnects
Re: Last used skin -
Stanford - 27.09.2015
Did you make sure that the name of the row is skinid when you read/write?