01.01.2015, 20:26
(
Последний раз редактировалось nezo2001; 03.01.2015 в 10:35.
)
Basic Admins Commands
This is my first tutorial i decided to make it to help newbies in scripting and making admin commandsFirst:
Slap
We use this command to put the player a few meters above in the sky to decrease their health
PHP код:
CMD:slap(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] != 0)
{
new targetid;
new Float:x, Float:y, Float:z;
GetPlayerPos(targetid, x, y, z);
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /slap [id]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
SetPlayerPos(targetid, x, y, z+5);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You can't use this command");
}
return 1;
}
PHP код:
if(PlayerInfo[playerid][pAdmin] != 0) // this line check if the admin level of the player that saves in the player file if it != "not equal" 0 run the command.
PHP код:
new targetid; //this define the variable that will store the target id that the player write.
PHP код:
new Float:x, Float:y, Float:z; //define the varable to get the player pos.
PHP код:
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /slap [id]"); //in this line we check if the player write the command rightor not if he typed /slap only it will send him a message tell him the right usage.
PHP код:
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");//this check if the targetid that the player typed is connect or not and if not send him a message .
PHP код:
SetPlayerPos(targetid, x, y, z+5); //This is the aim of the command to set the player pos "That we get it before and stored it" and add to it 5 meter "z = the height of the player".
PHP код:
}
else //if the player doesn't have the perimission:
{
PHP код:
SendClientMessage(playerid, COLOR_RED, "You can't use this command"); //Send to him a message and return 1 at the end of the command.
}
return 1;
}
Second:
Sethp
We use this command to set a player's healthPHP код:
CMD:sethp(playerid, params[])
{
new targetid; //as explained above
new amount; //to store the amount of the health
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command"); //Another way to give the player the perimission
if(sscanf(params, "ui", targetid, amount)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /sethp [id] (amount)"); //as explained above
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected"); //as explained above
SetPlayerHealth(targetid, amount); //set the targetid health with the amount of the admin typed
SendClientMessage(targetid, COLOR_GREEN, "An admin changed your health"); //Send a message to the target id that there is an admin changed his health
return 1;
}
akill
We use this command to kill a player
PHP код:
CMD:akill(playerid, params[])
{
ew targetid;
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command"); //As explained above
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected"); //As explained above
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /akill [id]"); //As explained above
SetPlayerHealth(targetid, 0); //Set the player health to 0 "Kill him"
SendClientMessage(targetid, COLOR_GREEN, "An admin killed you");
return 1;
}
SetArmour
To set a player armourPHP код:
CMD:setarmour(playerid, params[])
{
new targetid; //As explained at the very above :D
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command"); //As explained above
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /setarmour [id]");//As explained above
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");//As explained above
SetPlayerArmour(targetid, 100.0); //Give him a full armour level
SendClientMessage(targetid, COLOR_GREEN, "An admin added an armour to you");
return 1;
}
Freeze
We use this command to prevent the player from move or do anythingAll as explained above ecxept the things that i will explain
PHP код:
CMD:freeze(playerid, params[])
{
new targetid;
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /freeze [id]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
TogglePlayerControllable(targetid,0);//This prevent the player from control his body in the game
return 1;
}
Unfreeze
We use this command to unfreeze the playerAll as above ecxept
PHP код:
TogglePlayerControllable(targetid,0);
PHP код:
TogglePlayerControllable(targetid,1);
GiveMoney
We use this command to give the player an amount of moneyPHP код:
CMD:givecash(playerid, params[])
{
new targetid;
new amount;
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
if(sscanf(params, "ui", targetid, amount)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /givecash [id] (amount)");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
GivePlayerMoney(targetid, amount); //Give the player an amount of money that the admin typed
SendClientMessage(targetid, COLOR_GREEN, "An admin gave you money");
return 1;
}
Ahmed_Nezoo