Setskin cmd
#1

This is the CMD
Код:
CMD:setskin(playerid, params[])
{
   new targetplayer, skinid; // targetplayer = (the player you want to set the skin of) skinid = (obviously the skin you want to set)
   if(!IsPlayerAdmin(playerid)) return 0; // You may choose if you whether wants this cmd to be used for rcon admins only or everyone, if you prefer for admins only, use this line.
{
   if(sscanf(params, "ui", targetplayer, skinid)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /setskin [ID] [skinid]"); // this line is for; if you type /setskin, you will receive a message displayed with the "Usage" part.
   if(skinid < 0 || skinid > 311) return SendClientMessage(playerid, COLOR_RED, "Error: Available skinids 0 - 311"); // This line is for; if an admin uses the cmd inproperly like, /setskin [ID] 401, the admin will receive an message displayed, "Error: Available skinids 0 - 311".  I will explain the code,  if(skinid < 0 (means you're not allowed to use a skin below the 0. and the other part, skinid > 311 (basically means, you're not allowed to use a skin above 311. I hope you have learned the meanings of < > in school.
   if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Error: Player is not connected!");
 // this line means nothing less than detecting if the player is connected.
   new string[150], pName[MAX_PLAYER_NAME]; // string[150] = just the characters of the format that will be used later. pName[MAX_PLAYER_NAME] = for detecting the player's name.
   SetPlayerSkin(targetplayer, skinid); // That's basically the code of the /setskin
   format(string, sizeof string, "Your skinid has been set by an admin to %i", skinid); // %i in the format is the skinid
   SendClientMessage(targetplayer, COLOR_GREEN, string); // Sending the player a message in GREEN, as you can see, and string means the string I have made in the format above.
   GetPlayerName(targetplayer, pName, MAX_PLAYER_NAME); // Detecting the player name.
   format(string, sizeof string, "You have set %s's skinid to %i", pName, skinid); // Yep you have noticed it good, the second format. This format will be sent to the ADMIN who gives the skinids to players.
   SendClientMessage(playerid, COLOR_WHITE, string); // This message will be send to the Admin with a WHITE color.
}
return 1;
And the errors
Код:
D:\server\samp\gamemodes\abrffnew.pwn(394) : warning 217: loose indentation
D:\server\samp\gamemodes\abrffnew.pwn(395) : error 075: input line too long (after substitutions)
D:\server\samp\gamemodes\abrffnew.pwn(397) : warning 217: loose indentation
D:\server\samp\gamemodes\abrffnew.pwn(397) : error 029: invalid expression, assumed zero
D:\server\samp\gamemodes\abrffnew.pwn(397) : error 017: undefined symbol "in"
D:\server\samp\gamemodes\abrffnew.pwn(397) : error 017: undefined symbol "school"
D:\server\samp\gamemodes\abrffnew.pwn(397) : fatal error 107: too many error messages on one line

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


5 Errors.
Reply
#2

error came from:
PHP код:
// This line is for; if an admin uses the cmd inproperly like, /setskin [ID] 401, the admin will receive an message displayed, "Error: Available skinids 0 - 311".  I will explain the code,  if(skinid < 0 (means you're not allowed to use a skin below the 0. and the other part, skinid > 311 (basically means, you're not allowed to use a skin above 311. I hope you have learned the meanings of < > in school. 
because it very long line
try this one:
PHP код:
CMD:setskin(playeridparams[])
{
   new 
targetplayerskinid// targetplayer = (the player you want to set the skin of) skinid = (obviously the skin you want to set)
   
if(!IsPlayerAdmin(playerid)) return 0// You may choose if you whether wants this cmd to be used for rcon admins only or everyone, if you prefer for admins only, use this line.
   
{
   if(
sscanf(params"ui"targetplayerskinid)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /setskin [ID] [skinid]"); // this line is for; if you type /setskin, you will receive a message displayed with the "Usage" part.
   
if(skinid || skinid 311) return SendClientMessage(playeridCOLOR_RED"Error: Available skinids 0 - 311");
   
// This line is for; if an admin uses the cmd inproperly like, /setskin [ID] 401, the admin will receive an message displayed, "
   // Error: Available skinids 0 - 311".  I will explain the code,  if(skinid < 0 (means you're not allowed to use a skin below the 0. and the other part, skinid > 311 (basically means, you're not allowed to use a skin above 311. I hope you have learned the meanings of < > in school.
   
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Error: Player is not connected!");
 
// this line means nothing less than detecting if the player is connected.
   
new string[150], pName[MAX_PLAYER_NAME]; // string[150] = just the characters of the format that will be used later. pName[MAX_PLAYER_NAME] = for detecting the player's name.
   
SetPlayerSkin(targetplayerskinid); // That's basically the code of the /setskin
   
format(stringsizeof string"Your skinid has been set by an admin to %i"skinid); // %i in the format is the skinid
   
SendClientMessage(targetplayerCOLOR_GREENstring); // Sending the player a message in GREEN, as you can see, and string means the string I have made in the format above.
   
GetPlayerName(targetplayerpNameMAX_PLAYER_NAME); // Detecting the player name.
   
format(stringsizeof string"You have set %s's skinid to %i"pNameskinid); // Yep you have noticed it good, the second format. This format will be sent to the ADMIN who gives the skinids to players.
   
SendClientMessage(playeridCOLOR_WHITEstring); // This message will be send to the Admin with a WHITE color.
   
}
   return 
1;
 } 
Reply
#3

Working, thanks alot dude! +REP when I will be able to

How can I do in that command to show the name of the admin who set his skin?
Reply
#4

Why is not doing anything? I type the command and I don't get the 'Usage' and if I type the id is doing nothing.
Example /setskin
nothing

Example /setskin 0 3 - NOTHING

Код:
CMD:setskin(playerid, params[])
{
   new targetplayer, skinid;
   if (PlayerInfo[playerid][pAdmin] < 1)
   //if(IsPlayerAdmin(playerid)) return 0;
   {
   if(sscanf(params, "ui", targetplayer, skinid)) return SendClientMessage(playerid, COLOR_ORANGE, "<Usage> /setskin [ID] [skinid]"); // this line is for; if you type /setskin, you will receive a message displayed with the "Usage" part.
   if(skinid < 0 || skinid > 311) return SendClientMessage(playerid, COLOR_RED, "<Error> Available skinids 0 - 311");
   if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "<Error> Player is not connected!");
   //==-==
   new string[150], pName[MAX_PLAYER_NAME];
   SetPlayerSkin(targetplayer, skinid);
   format(string, sizeof string, "<ACCOUNT> Your skinid has been set by an admin to %i", skinid);
   SendClientMessage(targetplayer, COLOR_GREEN, string);
   GetPlayerName(targetplayer, pName, MAX_PLAYER_NAME);
   format(string, sizeof string, "<AdmCmd> You have set %s's skinid to %i", pName, skinid);
   SendClientMessage(playerid, COLOR_WHITE, string);
   }
   return 1;
}
I added
Код:
 if (PlayerInfo[playerid][pAdmin] < 1)
Due to this? I set my admin to 6 in userfiles

How do I make it for admin 1+? And working
Reply
#5

PHP код:
CMD:setskin(playeridparams[])
{
   new 
targetplayerskinid// targetplayer = (the player you want to set the skin of) skinid = (obviously the skin you want to set)
   
if(!IsPlayerAdmin(playerid)) return 0// You may choose if you whether wants this cmd to be used for rcon admins only or everyone, if you prefer for admins only, use this line.
   
{
   if(
sscanf(params"ui"targetplayerskinid)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /setskin [ID] [skinid]"); // this line is for; if you type /setskin, you will receive a message displayed with the "Usage" part.
   
if(skinid || skinid 311) return SendClientMessage(playeridCOLOR_RED"Error: Available skinids 0 - 311");
   
// This line is for; if an admin uses the cmd inproperly like, /setskin [ID] 401, the admin will receive an message displayed, "
   // Error: Available skinids 0 - 311".  I will explain the code,  if(skinid < 0 (means you're not allowed to use a skin below the 0. and the other part, skinid > 311 (basically means, you're not allowed to use a skin above 311. I hope you have learned the meanings of < > in school.
   
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Error: Player is not connected!");
 
// this line means nothing less than detecting if the player is connected.
   
new string[150], aName[MAX_PLAYER_NAME],pName[MAX_PLAYER_NAME]; // string[150] = just the characters of the format that will be used later. pName[MAX_PLAYER_NAME] = for detecting the player's name.
   
SetPlayerSkin(targetplayerskinid); // That's basically the code of the /setskin
   
GetPlayerName(playeridaNameMAX_PLAYER_NAME);
   
format(stringsizeof string"Your skinid has been set by admin %s to %i"aName,skinid); // %i in the format is the skinid
   
SendClientMessage(targetplayerCOLOR_GREENstring); // Sending the player a message in GREEN, as you can see, and string means the string I have made in the format above.
   
GetPlayerName(targetplayerpNameMAX_PLAYER_NAME); // Detecting the player name.
   
format(stringsizeof string"You have set %s's skinid to %i"pNameskinid); // Yep you have noticed it good, the second format. This format will be sent to the ADMIN who gives the skinids to players.
   
SendClientMessage(playeridCOLOR_WHITEstring); // This message will be send to the Admin with a WHITE color.
   
}
   return 
1;
 } 
Код:
 if (PlayerInfo[playerid][pAdmin] < 1)
< mean less than
> mean more than
try:
PHP код:
 if (PlayerInfo[playerid][pAdmin] >= 1
or:
PHP код:
CMD:setskin(playeridparams[])
{
   new 
targetplayerskinid// targetplayer = (the player you want to set the skin of) skinid = (obviously the skin you want to set)
   
if (PlayerInfo[playerid][pAdmin] >= 1) {
   if(
sscanf(params"ui"targetplayerskinid)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /setskin [ID] [skinid]"); // this line is for; if you type /setskin, you will receive a message displayed with the "Usage" part.
   
if(skinid || skinid 311) return SendClientMessage(playeridCOLOR_RED"Error: Available skinids 0 - 311");
   
// This line is for; if an admin uses the cmd inproperly like, /setskin [ID] 401, the admin will receive an message displayed, "
   // Error: Available skinids 0 - 311".  I will explain the code,  if(skinid < 0 (means you're not allowed to use a skin below the 0. and the other part, skinid > 311 (basically means, you're not allowed to use a skin above 311. I hope you have learned the meanings of < > in school.
   
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Error: Player is not connected!");
 
// this line means nothing less than detecting if the player is connected.
   
new string[150], aName[MAX_PLAYER_NAME],pName[MAX_PLAYER_NAME]; // string[150] = just the characters of the format that will be used later. pName[MAX_PLAYER_NAME] = for detecting the player's name.
   
SetPlayerSkin(targetplayerskinid); // That's basically the code of the /setskin
   
GetPlayerName(playeridaNameMAX_PLAYER_NAME);
   
format(stringsizeof string"Your skinid has been set by admin %s to %i"aName,skinid); // %i in the format is the skinid
   
SendClientMessage(targetplayerCOLOR_GREENstring); // Sending the player a message in GREEN, as you can see, and string means the string I have made in the format above.
   
GetPlayerName(targetplayerpNameMAX_PLAYER_NAME); // Detecting the player name.
   
format(stringsizeof string"You have set %s's skinid to %i"pNameskinid); // Yep you have noticed it good, the second format. This format will be sent to the ADMIN who gives the skinids to players.
   
SendClientMessage(playeridCOLOR_WHITEstring); // This message will be send to the Admin with a WHITE color.
   
} else return SendClientMessage(playerid0xFF0000AA,"you need to be administrator to use this command.");
   return 
1;
 } 
Reply
#6

Bro, remove those // lines.. I did that for explanation.
Reply
#7

AndreiWow, add this to your CMD:

PHP код:
if(skinid == 74) return SendClientMessage(playeridCOLOR_RED"Error: This skinid is unavailable."); 
skinid 74 is CJ, and CJ is skinid 0, so 74 is now unavailable.
Reply
#8

Thanks, i solved it, I cant give REP
Reply
#9

Oh, why not?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)