09.01.2014, 12:29
(
Последний раз редактировалось MatriXgaMer; 09.01.2014 в 15:37.
)
Hey Guys
Today we are making an SetSkin command.
We need 2 includes, zcmd and sscanf. (They are no made by me!)
Are you ready? Ok let's start.
We will do it like this(put it on the top of your script), and the color what we will use.
Now also under #include <a_samp> add:
Thats why we downloaded ZCMD and SSCANF.
Ok when you finished all this lets start making the command
So what we did here we added "return 1;" which stands for that the command is succesfuly exicuted.
Now lets do this:
Why we added pID? pID=TargetID the target of setskin, sID=SkinID the skin that we will set the target and name= PlayerName= SenderName we are getting the sender name and str= string. You are asking why ? You will know later.
Now we will add more stuff to it:
We added IsPlayerAdmin = If the player is Rcon Admin if not that the command return false(0) and GetPlayerName= Getting the sendername/playername.
Ok you are not cunfused any more ? Greate lets add more stuff:
We added SSCANF= Params if the player writes setskin only its shows /setskin [PlayerID/Name] [SkinID].
Ok lets finish the command:
We added SetPlayerSkin , and used sscanf and formated the message to use in SCM(SendClientMessage) also checked if the pID is connected and the sID is valid.
Now we are ready to use the command in our server!
Today we are making an SetSkin command.
We need 2 includes, zcmd and sscanf. (They are no made by me!)
Are you ready? Ok let's start.
We will do it like this(put it on the top of your script), and the color what we will use.
pawn Код:
#define COLOR_RED 0xFF0000FF
pawn Код:
#include <zcmd>
#include <sscanf2>
Ok when you finished all this lets start making the command
pawn Код:
CMD:setskin(playerid, params[])
{
return 1;
}
Now lets do this:
pawn Код:
CMD:setskin(playerid, params[])
{
new pID,sID,name[MAX_PLAYER_NAME];
return 1;
}
Now we will add more stuff to it:
pawn Код:
CMD:setskin(playerid, params[])
{
if(!IsPlayerAdmin(playerid))return 0;
new pID,sID, name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return 1;
}
Ok you are not cunfused any more ? Greate lets add more stuff:
pawn Код:
CMD:setskin(playerid, params[])
{
if(IsPlayerAdmin(playerid))return 0;
new pID,sID, name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(sscanf(params, "ui",pID,sID))return SendClientMessage(playerid, COLOR_RED,"INFO: /setskin [PlayerID/Name] [SkinID]");
return 1;
}
Ok lets finish the command:
pawn Код:
CMD:setskin(playerid, params[])
{
if(IsPlayerAdmin(playerid))return 0;
new pID,sID, name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof(name));
if(sscanf(params, "ui",pID,sID))return SendClientMessage(playerid, COLOR_RED,"INFO: /setskin [PlayerID/Name] [SkinID]");
if(pID == INVALID_PLAYER_ID)return SendClientMessage(playerid, COLOR_RED, "Player not found.");
if(sID > 299)return SendClientMessage(playerid, COLOR_RED, "Skin not found.");
SetPlayerSkin(pID,sID);
format(str, sizeof(str), "Admin %s has set your skin to %i.", name, sID);
SendClientMessage(pID, COLOR_RED,str);
return 1;
}
Now we are ready to use the command in our server!