31.01.2013, 11:10
(
Последний раз редактировалось M3mPHi$_S3; 31.01.2013 в 15:12.
Причина: tiitle
)
Starting...
First We Will Define includes and other simple things
In Case
When we will define it on command so this will not allow a player to use command if he will not be an admin
Now we will start Creating our Command
Now we will Use this now our command
Function
were in used from
This "1" Mean once a player is on-duty he cant use /duty command again.
This will set the player duty +1 mean counted
Hope you'll like it ."FULL CODE CAN BE FOUND HERE"
First We Will Define includes and other simple things
PHP код:
#include <a_samp>
#include <zcmd> // The command Creator
#define RED 0xE60000FF // color red defination
new Aduty[MAX_PLAYERS];
new Adutycount;
- Now We will create a enum function which will not allow a simple player to use this command.0nly for admins
PHP код:
enum Player_Data
{
P_Level,
};
new P_DATA[MAX_PLAYERS][Player_Data];
Now we will start Creating our Command
PHP код:
CMD:duty(playerid, params[])
{
- Now we will define if a player is not admin he cant use a command FOr that we already created this
PHP код:
enum Player_Data
{
pLevel,
};
new P_DATA[MAX_PLAYERS][Player_Data];
PHP код:
CMD:aduty(playerid, prams[])
{
if (P_DATA[ playerid ][ P_Level ] < 1)return SendClientMessage( playerid,RED, "You are not high enough level to use this commands");
PHP код:
if (P_DATA[ playerid ][ P_Level ] < 1)
Код:
new P_DATA[MAX_PLAYERS][Player_Data];
- Now we will create a function which will not allowed a player to Spam the server repeating using the command so for that we will use this funtion Код:
new Aduty[MAX_PLAYERS];
PHP код:
CMD:aduty(playerid, params[])
{
if (P_DATA[ playerid ][ P_Level ] < 1)return SendClientMessage( playerid, "You are not high enough level to use this commands");
if(Aduty[playerid] == 1) // -- No need to explain about this ..
{
return GameTextForPlayer(playerid, "You are already in Duty-Mode. Use /offduty",3000,3);
}
- This was soem importante part of command In-case this all Now we will Function the command
PHP код:
new string[256]; // create String
format(string, sizeof(string), "[CAUTION]: Administrator %s Is Now On-Duty."); // Send info to server
SendClientMessageToAll(RED, string);
SendClientMesage( playerid, COLOR_YELLOW, "You are now on duty mode.USe /offduty to offduty !"); // Send information to %s player (command user)
SetPlayerHealth(playerid, 9999); // Set health to 9999 - As godmode
SetPlayerArmour(playerid, 9999); // set armour to 9999 - full armour
new Float:X;
new Float:Y;
new Float:Z;
GetPlayerPos(playerid,X,Y,Z);
CreateVehicle(425,X,Y+5,Z,1,1,1,90000); // This is spawn a HUNTER near %s Player
GivePlayerWeapon( playerid, 30, 100000); // guns
GivePlayerWeapon( playerid, 38, 100000); // guns
GivePlayerWeapon( playerid, 35, 100000); // guns
GivePlayerWeapon( playerid, 24, 100000); // guns
GivePlayerWeapon( playerid, 26, 100000); //guns
Aduty[playerid] =1;
Adutycount++;
return 1;
}
Код:
Aduty[playerid] =1; Adutycount++;
- Now we will create /offduty command
Код:
In /offduty all function are as same as /duty so No need to explain again and again
PHP код:
CMD:offduty(playerid, params[])
{
if (P_DATA[ playerid ][ P_Level ] < 1)return SendClientMessage( playerid, "You are not high enough level to use this commands");
if(Aduty[playerid] == 0)
{
return GameTextForPlayer(playerid, "You are not in Duty-Mode. Use /aduty",3000,3);
}
new string[256];
format(string, sizeof(string), "[CAUTION]: Administrator %s Is Now Off-Duty.");
SendClientMessageToAll(RED, string);
SetPlayerHealth(playerid, 100); // set player health to normal 100
ResetPlayerWeapons(playerid); // disarm the %s player
Aduty[playerid] =0; // in-active the %s player duty
Adutycount--; // Same
return 1;
}