#1

Hey! I want to make a command that changes the players skin, but I get the following error messages:
Note: I kind of improvised the code cause I dont really know how to script properly

Код:
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(182) : error 001: expected token: "-identifier-", but found "["
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(184) : error 017: undefined symbol "yellow"
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(185) : error 017: undefined symbol "red"
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(186) : error 017: undefined symbol "Jstring"
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(186) : error 017: undefined symbol "Jstring"
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(186) : error 029: invalid expression, assumed zero
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(186) : fatal error 107: too many error messages on one line

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


7 Errors.
And this is the code:

Код:
CMD:skin(playerid,params[])
{
	new playerState = GetPlayerState(playerid);
    if(playerState == PLAYER_STATE_SPAWNED)
	{
        new skinid,[001];
	    if(sscanf(params, "i", skinid)) return
		SendClientMessage(playerid, yellow, "Usage: /skin [skin ID]") ;
		if(skinid < 0 || skinid > 299) return SendClientMessage(playerid, red, "Invaild skin ID!");
		format(Jstring,sizeof(Jstring),"You have set your skin ID to %d.", skinid);
		SendClientMessage(playerid,yellow,Jstring);
		[playerid][Skin] = skinid;
		SetPVarInt(playerid,"Useskin",1);
		return SetPlayerSkin(playerid, skinid);
	}
	else return ShowMessage(playerid, red, 1);
}
Thanks in beforehand.
Reply
#2

I can show you my skin cmd code.
I don't exactly understand your code lol

PHP код:
CMD:setskin(playeridparams[])
{
    new 
targetplayerskinid;
    if(
sscanf(params"ui"targetplayerskinid)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /setskin [ID] [skinid]");
    if(
skinid || skinid 311) return SendClientMessage(playeridCOLOR_RED"Error: Available skinids 0 - 311");
    if(
skinid == 74) return SendClientMessage(playeridCOLOR_RED"Error: This skinid is unavailable!");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Error: Player is not connected!");
    new 
string[64], pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
    
SetPlayerSkin(targetplayerskinid);
    
format(stringsizeof string"Your skin has been set to %i by an admin."skinid);
    
SendClientMessage(targetplayerCOLOR_GREENstring);
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    
GetPlayerName(targetplayerpName2MAX_PLAYER_NAME);
    
format(stringsizeof string"You have set %s's skinid to %i."pName2skinid);
    
printf("[SETSKIN] %s has set the skin of %s to %i"pNamepName2skinid);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    return 
1;

Reply
#3

Try this. You seem to be using alot of undefined things...

PHP код:
CMD:skin(playerid,params[])
{
    new 
playerState GetPlayerState(playerid);
    if(
playerState == PLAYER_STATE_SPAWNED)
    {
        new 
skinid;
        if(
sscanf(params"i"skinid)) return SendClientMessage(playeridyellow"Usage: /skin [skin ID]") ;
        if(
skinid || skinid 311) return SendClientMessage(playeridred"Invaild skin ID!");
        new 
Jstring[128];
        
format(Jstringsizeof(Jstring), "You have set your skin ID to %i."skinid);
        
SendClientMessage(playerid0xFDEE00FFJstring);
        
SetPVarInt(playerid,"Useskin",1);
        
SetPlayerSkin(playeridskinid);
        return 
1;
    }
    else return 
ShowMessage(playeridred1);

Reply
#4

Yeah I just mixed some random code together that looked like it'd work(in my head)

Get this when I use your code
Код:
C:\Users\John\Desktop\SA-MP  servers\DM Server\gamemodes\bare.pwn(192) : error 017: undefined symbol "ShowMessage"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#5

Fixed Sellize's code.

PHP код:
CMD:skin(playerid,params[])
{
    new 
playerState GetPlayerState(playerid);
    if(
playerState == PLAYER_STATE_SPAWNED)
    {
        new 
skinid;
        if(
sscanf(params"i"skinid)) return SendClientMessage(playeridyellow"Usage: /skin [skin ID]") ;
        if(
skinid || skinid 311) return SendClientMessage(playeridred"Invaild skin ID!");
        new 
Jstring[128];
        
format(Jstringsizeof(Jstring), "You have set your skin ID to %i."skinid);
        
SendClientMessage(playerid0xFDEE00FFJstring);
        
SetPVarInt(playerid,"Useskin",1);
        
SetPlayerSkin(playeridskinid);
        return 
1;
    }
    else return 
SendClientMessage(playerid, -1"You need to be spawned!");

Reply
#6

Strange, I get this when I use the command.

Reply
#7

Check this

Quote:

CMDkin( playerid, params[ ] )
{
new liSkin;
if ( sscanf( params, "i", liSkin ) )
return SendClientMessage( playerid, COLOR_LIGHTBLUE, "USAGE: {FFFF00}/skin [SkinID]" );

if ( liSkin < 0 || liSkin > 299 )
return SendError( playerid, "That skin don't exists!" );

SetPlayerSkin( playerid, liSkin );
return ( 1 );
else return SendClientMessage(playerid, -1, "You need to be spawned!");
}

Reply
#8

Quote:
Originally Posted by Counterafk
Посмотреть сообщение
Strange, I get this when I use the command.

It seems that the PLAYER_STATE_SPAWNED is set only the moment the player spawns so you can't use it in a command like that.

I got the info here: https://sampforum.blast.hk/showthread.php?tid=112857

I'd recommend taking out the condition and making the code like this:

PHP код:
CMD:skin(playerid,params[]) 

    new 
skinid
    if(
sscanf(params"i"skinid)) return SendClientMessage(playeridyellow"Usage: /skin [skin ID]") ; 
    if(
skinid || skinid 311) return SendClientMessage(playeridred"Invaild skin ID!"); 
    new 
Jstring[128]; 
    
format(Jstringsizeof(Jstring), "You have set your skin ID to %i."skinid); 
    
SendClientMessage(playerid0xFDEE00FFJstring); 
    
SetPVarInt(playerid,"Useskin",1); 
    
SetPlayerSkin(playeridskinid); 
    return 
1

Or if you want, you could the command for admins only.
Reply
#9

Thanks, man!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)