/setskin
#1

Excuse me guys i made this code but im new in pawn lenguage and i want to save the skin in my variable pSkin in user folder how can i do it?

PHP Code:
CMD:setskin(playeridparams[])
{
    new 
useridskinid;
    if (
sscanf(params"ui"useridskinid))
        return 
SendClientMessage(playeridCOLOR_GRAD"USAGE: /setskin [Playerid/PartOfName] [Skin ID]");
    if (!
IsPlayerConnected(userid))
        return 
SendClientMessage(playeridCOLOR_GRAD"That player is Offline!");
    if (!(
<= skinid <= 311))
        return 
SendClientMessage(playeridCOLOR_GRAD"Skin can't be below 0 or above 311");
    
    
SetPlayerSkin(useridskinid);
    return 
1;

Reply
#2

Assuming you are already saving the pSkin variable, add this below SetPlayerSkin:

Code:
pSkin[playerid] = skinid;
Reply
#3

HTML Code:
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : error 028: invalid subscript (not an array or too many subscripts): "pSkin"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : warning 215: expression has no effect
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : error 001: expected token: ";", but found "]"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : error 029: invalid expression, assumed zero
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#4

Long story short: Learn how to work with SQL, and run a simple query:
"UPDATE `players` SET 'pSkin' = '%i' WHERE `id` = '%i' LIMIT 1"
None of us can provide you with proper answer, since you have no clue what an enumerator is, and how to cope with it. Good luck on your long journey!
Reply
#5

Quote:
Originally Posted by Jaua10
View Post
HTML Code:
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : error 028: invalid subscript (not an array or too many subscripts): "pSkin"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : warning 215: expression has no effect
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : error 001: expected token: ";", but found "]"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : error 029: invalid expression, assumed zero
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1402) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
You told us the variable was pSkin and those warnings are showing us that it isn't. You need to find the actual name of the variable used to save skins or create it yourself if there isn't one.
Reply
#6

i got this

PHP Code:
enum pInfo
{
    
pPass,
    
pCash,
    
pAdmin,
    
pKills,
    
pDeaths,
    
pBanished,
    
pFaction
    
pFacrank,
    
pFacleader,
    
pSkin
}
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Password",PlayerInfo[playerid][pPass]);
    
INI_Int("Cash",PlayerInfo[playerid][pCash]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    
INI_Int("Kills",PlayerInfo[playerid][pKills]);
    
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    
INI_Int("Faction",PlayerInfo[playerid][pFaction]);
    
INI_Int("Facrank",PlayerInfo[playerid][pFacrank]);
    
INI_Int("Facleader",PlayerInfo[playerid][pFacleader]);
    
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
     return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    
INI_WriteInt(File,"Faction",PlayerInfo[playerid][pFaction]);//saves the players faction id on disconnect
    
INI_WriteInt(File,"Facrank",PlayerInfo[playerid][pFacrank]);//saves the players faction rank on disconnect
    
INI_WriteInt(File,"Facleader",PlayerInfo[playerid][pFacleader]);//saves the players faction leadership status on disconnect
    
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    
INI_Close(File);
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch( 
dialogid )
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new 
INI:File INI_Open(UserPath(playerid));
                
INI_SetTag(File,"data");
                
INI_WriteInt(File,"Password",udb_hash(inputtext));
                
INI_WriteInt(File,"Cash",0);
                
INI_WriteInt(File,"Admin",0);
                
INI_WriteInt(File,"Kills",0);
                
INI_WriteInt(File,"Deaths",0);
                
INI_WriteInt(File,"Faction",0);
                
INI_WriteInt(File,"Facrank",0);
                
INI_WriteInt(File,"Facleader",0);
                
INI_WriteInt(File,"Skin",0);
                
INI_Close(File);
                
SetSpawnInfo(playerid001958.331343.1215.36269.15000000);
                
SpawnPlayer(playerid);
                
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_WHITE"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
            }
        }
        case 
DIALOG_LOGIN:
        {
            if ( !
response ) return Kick playerid );
            if( 
response )
            {
                if(
udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                    
GivePlayerMoney(playeridPlayerInfo[playerid][pCash]);
                    
ShowPlayerDialog(playeridDIALOG_SUCCESS_2DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_WHITE"You have successfully logged in!","Ok","");
                }
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 
1;
            }
        }
    }
    return 
1;
}
CMD:setskin(playeridparams[])
{
    new 
useridskinid;
    if (
sscanf(params"ui"useridskinid))
        return 
SendClientMessage(playeridCOLOR_GRAD"USAGE: /setskin [Playerid/PartOfName] [Skin ID]");
    if (!
IsPlayerConnected(userid))
        return 
SendClientMessage(playeridCOLOR_GRAD"That player is Offline!");
    if (!(
<= skinid <= 311))
        return 
SendClientMessage(playeridCOLOR_GRAD"Skin can't be below 0 or above 311");
    
    
SetPlayerSkin(useridskinid);
    
pSkin[playerid] = skinid;
    return 
1;

Reply
#7

You have it in an enum, so the correct line would be.

Code:
PlayerInfo[playerid][pSkin] = skinid;
However, you should have maybe showed the code you have shown above originally so you would have got the help quicker without the confusion.

Maybe it's worth starting with smaller scale scripts if you're learning from released projects on these forums as to pick up the basics before jumping straight into full gamemode. Also check out the tutorials board for extra help as well as the wiki.

EDIT: It also seems you were already helped with this issue a few days ago: https://sampforum.blast.hk/showthread.php?tid=641753 although the same issues arose due to lack of information.
Reply
#8

alright i have no errors now, but still without saving the skins when i relog, what can i do guys?
Reply
#9

Are you setting the player's skin when they spawn? Example, once the player's data has been loaded you would use:

Code:
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
Reply
#10

Quote:
Originally Posted by Burridge
View Post
Are you setting the player's skin when they spawn? Example, once the player's data has been loaded you would use:

Code:
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
when i put this in my code, i cant change the skin number because always give me CJ skin with any number i put for example:

if i use /setskin 0 249 give to me CJ skin...same with any other number always give me CJ skin
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)