22.05.2014, 16:48
(
Last edited by Ghazal; 27/05/2014 at 08:55 AM.
)
Hello guys, This is my second tutorial, If this tutorial helped you remember to rep me.
Let's start.
What includes are we going to use?
Question:Why are you using specially ZCMD?
Answer:ZCMD is the fastest command processor.
After Defining the includes.
Let's start scripting!
We will need to define "PlayerInfo" And "p_info" So we can save the player skin.
Now we defined p_info.
We are going to define PlayerInfo now.
Now we defined Playerinfo & p_info.
We will also need to define a variable which is " SkinSaving "
Question: Where should i add this?
Answer: You should add this at the top of your script.
Let's start creating the commands!
As we are using ZCMD We will need to add this.
Now, lets add something like " new "
Question: Why did you add this?
Answer: I added this so we the script will get the player skin id and set his skin to it every time he spawn!
Now lets add something so the player wont keep saving skin ids when he already have one saved.
As we defined the variable as SkinSaving above, we will use this.
According to sscanf specifiers
Question:Why did you mention this here?
Answer: Because ill let the player know what skin id he saved.
Now lets start scripting if the player doesn't have a skin saved.
Now we did the /saveskin command!
Lets do /delskin.
Firstly we will need to prevent people from using the command if they didnt save their skin!
Now, The players wont be able to use this command if they didn't use /saveskin.
Let's add if the player used saveskin command!
Question:Why do we always use else if?
Answer: We are using else if because at the top of the command we used if.
Now, last step.
We need to add this under onplayerspawn so it will check if he has saved skin and auto sets him to it if he has.
Now, I am going to give an example for /saveskin & /delskin & /skin
/saveskin :
/delskin :
/skin :
Oh, I forgot to define the COLOR_GREY !
Here you go with the define.
Let's start.
What includes are we going to use?
pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf>
Answer:ZCMD is the fastest command processor.
After Defining the includes.
Let's start scripting!
We will need to define "PlayerInfo" And "p_info" So we can save the player skin.
pawn Code:
enum p_Info
{
eSkin
}
We are going to define PlayerInfo now.
pawn Code:
new PlayerInfo[MAX_PLAYERS][p_Info];
We will also need to define a variable which is " SkinSaving "
pawn Code:
new SkinSaving[MAX_PLAYERS];
Answer: You should add this at the top of your script.
Let's start creating the commands!
As we are using ZCMD We will need to add this.
pawn Code:
CMD:saveskin(playerid,params[]) //The command we are going to use to save the player skin
pawn Code:
new skinid = GetPlayerSkin(playerid);
Answer: I added this so we the script will get the player skin id and set his skin to it every time he spawn!
Now lets add something so the player wont keep saving skin ids when he already have one saved.
As we defined the variable as SkinSaving above, we will use this.
pawn Code:
if(SkinSaving[playerid] == 1)
{
SendClientMessage(playerid,COLOR_GREY,"You already saved a skin before! to delete it you can use /delskin !");
}
Code:
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
Answer: Because ill let the player know what skin id he saved.
Now lets start scripting if the player doesn't have a skin saved.
pawn Code:
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;
}
Lets do /delskin.
Firstly we will need to prevent people from using the command if they didnt save their skin!
pawn Code:
if(SkinSaving[playerid] == 0)
{
SendClientMessage(playerid,COLOR_GREY,"You don't have a skin saved to delete it!");
}
Let's add if the player used saveskin command!
pawn Code:
else if(SkinSaving[playerid] == 1)
{
SendClientMessage(playerid,COLOR_GREY,"You have deleted your skin.");
SkinSaving[playerid] = 0;
}
Answer: We are using else if because at the top of the command we used if.
Now, last step.
We need to add this under onplayerspawn so it will check if he has saved skin and auto sets him to it if he has.
pawn Code:
if(SkinSaving[playerid] = 1)
{
SetPlayerSkin(playerid,PlayerInfo[playerid][eSkin]);
}
/saveskin :
pawn Code:
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;
}
pawn Code:
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;
}
pawn Code:
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.
}
Here you go with the define.
pawn Code:
#define COLOR_GREY (0x808080FF)