#include <a_samp>
#include <zcmd>
#include <sscanf>
enum p_Info
{
eSkin
}
new PlayerInfo[MAX_PLAYERS][p_Info];
new SkinSaving[MAX_PLAYERS];
CMD:saveskin(playerid,params[]) //The command we are going to use to save the player skin
new skinid = GetPlayerSkin(playerid);
if(SkinSaving[playerid] == 1)
{
SendClientMessage(playerid,COLOR_GREY,"You already saved a skin before! to delete it you can use /delskin !");
}
Specifier(s) Name Example values b Binary 01001, 0b1100 c Character a, o, * f Float 0.7, -99.5 g IEEE Float 0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E h, x Hex 1A, 0x23 i, d Integer 1, 42, -10 l Logical true, false n Number 42, 0b010, 0xAC, 045 o Octal 045 12 q Bot name/id ShopBot, 27 r Player name/id ******, 42 u User name/id (bots and players) ******, 0
else if(SkinSaving[playerid] == 0)
{
PlayerInfo[playerid][eSkin] = skinid;
SkinSaving[playerid] = 1;
SendClientMessage(playerid,COLOR_GREY,"You have saved your skin, Every time you spawn your skin will be %d",skinid);
}
return 1;
}
if(SkinSaving[playerid] == 0)
{
SendClientMessage(playerid,COLOR_GREY,"You don't have a skin saved to delete it!");
}
else if(SkinSaving[playerid] == 1)
{
SendClientMessage(playerid,COLOR_GREY,"You have deleted your skin.");
SkinSaving[playerid] = 0;
}
if(SkinSaving[playerid] = 1)
{
SetPlayerSkin(playerid,PlayerInfo[playerid][eSkin]);
}
CMD:saveskin(playerid,params[])
{
new skinid = GetPlayerSkin(playerid);
if(SkinSaving[playerid] == 1)
{
SendClientMessage(playerid,COLOR_GREY,"You already saved a skin before! to delete it you can use /delskin !");
}
else if(SkinSaving[playerid] == 0)
{
PlayerInfo[playerid][eSkin] = skinid;
SkinSaving[playerid] = 1;
SendClientMessage(playerid,COLOR_GREY,"You have saved your skin, Every time you spawn your skin will be %d",skinid);
}
return 1;
}
CMD:delskin(playerid,params[])
{
if(SkinSaving[playerid] == 0)
{
SendClientMessage(playerid,COLOR_GREY,"You don't have a skin saved to delete it!");
}
else if(SkinSaving[playerid] == 1)
{
SendClientMessage(playerid,COLOR_GREY,"You have deleted your skin.");
SkinSaving[playerid] = 0;
}
return 1;
}
CMD:skin(playerid, params[]) // Creating the /skin command.
{
new skinid;
// If you want make this command only available for Rcon Admins, then remove // characters below this.
//if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You aren't allowed to use this command.");
if(sscanf(params, "d", skinid)) // d or i = integer, s = string and f = float! As you know skinid is an integer and i defined 'd'
return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /skin (skinid)"); // Player has used the command without params, then we send him a message.
// Now the variable 'skinid' contains the value that player has gave as params.
// Example /skin 294 and the variable contains now the value '294'
if(skinid > 299 || skinid < 0) // There are only from 0 - 299 skin id's and it should send a warning message
return SendClientMessage(playerid, 0xFF0000FF, "Invalid Skin ID!");
else if(skinid == 74)
return SendClientMessage(playerid, 0xFF0000FF, "Invalid Skin ID!"); //Added Line By Rittik.
SetPlayerSkin(playerid, skinid); // As you know the 'skinid' contains the value of player's given params.
return 1; // Of course we need return a value.
}
#define COLOR_GREY (0x808080FF)
CMD:skin(playerid, params[]) { new skinid; if(sscanf(params, "d", skinid)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /skin (skinid)"); if(skinid > 299 || skinid < 0) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Skin ID!"); else if(skinid == 74) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Skin ID!"); //Added Line By Me. SetPlayerSkin(playerid, skinid); Player_HasSkin[playerid] = true; Player_Skin[playerid] = skinid; return 1; }
Nice Job but skin 74 is an invalid skin id.
Code:
CMD:skin(playerid, params[]) { new skinid; if(sscanf(params, "d", skinid)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /skin (skinid)"); if(skinid > 299 || skinid < 0) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Skin ID!"); else if(skinid == 74) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Skin ID!"); //Added Line By Me. SetPlayerSkin(playerid, skinid); Player_HasSkin[playerid] = true; Player_Skin[playerid] = skinid; return 1; } |
if(SkinSaving[playerid] = 1) { SetPlayerSkin(playerid,PlayerInfo[playerid][eSkin]); }
if(SkinSaving[playerid] == 1) // or if(SkinSaving[playerid]) { { SetPlayerSkin(playerid,PlayerInfo[playerid][eSkin]); }
CMD:saveskin(playerid,params[])
{
new skinid = GetPlayerSkin(playerid);
if(SkinSaving[playerid] == 1) return SendClientMessage(playerid,COLOR_GREY,"You already saved a skin before! to delete it you can use /delskin !");//this is what I am talking about. Simply return it to save some typing mayhem... Esecially in long scripts.
else if(SkinSaving[playerid] == 0)
{
PlayerInfo[playerid][eSkin] = skinid;
SkinSaving[playerid] = 1;
SendClientMessage(playerid,COLOR_GREY,"You have saved your skin, Every time you spawn your skin will be %d",skinid);
}
return 1;
}
your script should work, but I have a little advice for you.
Instead of making so many if and elses, you can return the client messages. That will make your script shorter. example with /saveskin... pawn Code:
And you haven't added the stuff Rittik said, skin id 74 is really a invalid skin id. You shold add it in your tut. Otherwise great job. |