21.02.2013, 11:14
How to make /godon and /godoff commands. (Explaining)
What you will need:
zCmd - Zeex - Click me!
Getting started:
Lets start off by defining this color:
And including zCmd once you have downloaded the include.
We will now start off the tutorial.
The main Subject:
We will use a bool. The bool is used to check if the player already has godmode on or already has godmode off!
Add this to the top of your script, under the includes:
Now lets move onto the command. You can either change the line which checks if the player is an Admin, or you can use one of your own which you have defined in your Admin system.
This checks if the player is an Rcon Admin. If he is not, it will return a message to the player.
This checks if the Player already has godmode on, if he does, it will return a message.
This sets the Player's health so he can not be killed by another person.
This is a string which sends out a message to the whole server saying that the Administrator has turned on his godmode.
This line turns it to true, so when the player does /godon or /godoff, it can check if he already has it on/off.
I have explained the exact thing above, this turns his godmode off. Read above, if you do not understand.
I hope you have learned something from this - if you would like to request a new tutorial, just PM me or comment. Thanks
What you will need:
zCmd - Zeex - Click me!
Getting started:
Lets start off by defining this color:
pawn Код:
#define RED 0xFF0000FF
pawn Код:
#include <zcmd>
The main Subject:
We will use a bool. The bool is used to check if the player already has godmode on or already has godmode off!
Add this to the top of your script, under the includes:
pawn Код:
new
bool: playerGod[ MAX_PLAYERS ];
pawn Код:
CMD:godon( playerid, params[] )
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "You are not authorised to use this command");
if ( playerGod{ playerid } )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You already have god mode on!");
SetPlayerHealth(playerid, 9999999999.0);
SetPlayerArmour(playerid, 9999999999.0);
new
str[ 128 ];
format( str, sizeof ( str ), "[GODMODE - ON] Administrator %s has turned on his Godmode.", GetName( playerid ) );
SendClientMessageToAll(RED, str);
playerGod{ playerid } = true;
return 1;
}
pawn Код:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "You are not authorised to use this command");
pawn Код:
if ( playerGod{ playerid } )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You already have god mode on!");
pawn Код:
SetPlayerHealth(playerid, 9999999999.0);
SetPlayerArmour(playerid, 9999999999.0);
pawn Код:
new
str[ 128 ];
format( str, sizeof ( str ), "[GODMODE - ON] Administrator %s has turned on his Godmode.", GetName( playerid ) );
SendClientMessageToAll(RED, str);
pawn Код:
playerGod{ playerid } = true;
pawn Код:
CMD:godoff( playerid, params[] )
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "You are not authorised to use this command");
if ( !playerGod{ playerid } )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You already have god mode off!");
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
new
str[ 128 ];
format( str, sizeof ( str ), "[GODMODE - OFF] Administrator %s has turned off his Godmode.", GetName( playerid ) );
SendClientMessageToAll(RED, str);
playerGod{ playerid } = false;
return 1;
}
I hope you have learned something from this - if you would like to request a new tutorial, just PM me or comment. Thanks