Last used skin
#1

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?
Reply
#2

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.
Reply
#3

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
    return 
1;

PHP код:
public OnPlayerSpawn(playerid)
{
    
SetPlayerSkin(playeridpInfo[playerid][Skin]);
    return 
1;

Reply
#4

Quote:
Originally Posted by StreetRP
Посмотреть сообщение
PHP код:
public OnPlayerDisconnect(playeridreason)
{
    
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
    return 
1;

PHP код:
public OnPlayerSpawn(playerid)
{
    
SetPlayerSkin(playeridpInfo[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
Reply
#5

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!
Reply
#6

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);
Reply
#7

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!
Reply
#8

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
Reply
#9

Did you make sure that the name of the row is skinid when you read/write?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)