CMD:setgodmode(playerid,params[]) // This it's our command made with ZCMD ;
// ZCMD = A command processor made by Zeex [Thanks Zeex]
{ // We open brackelet !
new ID; // Making a Variable for ID. Wich represent the PlayerID of that player !
if(IsPlayerAdmin(playerid)) // This it's the Admin Variable. This is a variable for RCON Admin ;
// So you need first to log in as RCON, before using this command.
// Or change with your Admin Variable.
{ // Open second brackelet, before your admin variable !
if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]"); // If he makes something wrong, only /SetGodMode, will show to him Usage.
SetPlayerHealth(ID, 10000000); // Will sets to specified player GodMode. [100000000 Life]
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !"); // This will saw the Admin wich gonna sets GodMode to a player !
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !"); // This will saw player, wich Admin sets to it God Mode
} // Closing brackelet !
else // Else, if he use that command again on that player, will sets 100 life !
{ // Open brackelet
SetPlayerHealth(ID, 100); // Will sets to that player 100 life, for second use.
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!"); // This will saw the Admin wich writes second time /SetGodMode [ID]
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !"); // This will saw the player !
}
return 1; // We need to return 1, else we will get errors.
} // And we close the last brackelet.
/*
After you did this, your command will works.
It's a simple command, but unique.
*/
#include <a_samp>
#include <zcmd>
CMD:setgodmode(playerid,params[])
{
new ID;
if(PlayerInfo[playerid][Admin] >= 2)
{
if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]");
SetPlayerHealth(ID, 10000000);
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !");
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !");
}
else
{
SetPlayerHealth(ID, 100);
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
}
return 1;
}
else // Else, if he use that command again on that player, will sets 100 life !
{ // Open brackelet
SetPlayerHealth(ID, 100); // Will sets to that player 100 life, for second use.
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!"); // This will saw the Admin wich writes second time /SetGodMode [ID]
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !"); // This will saw the player !
return 1; // We need to return 1, else we will get errors.
} //
else
{
SetPlayerHealth(ID, 100);
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
}
else
{
SendClientMessage(playerid, -1, "{FF0000}ERROR: {15FF00}You are not authorized to use this command !");
}
It's bracket, not brackelet
pawn Код:
pawn Код:
The code has lots of errors, it wont work.. Besides that, good job to trying to write a tutorial ! |
// LOGICALLY INCORRECT CODE #include <a_samp> #include <zcmd> CMD:setgodmode(playerid,params[]) { new ID; if(PlayerInfo[playerid][Admin] >= 2) { if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]"); SetPlayerHealth(ID, 10000000); SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !"); SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !"); } else { SetPlayerHealth(ID, 100); SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!"); SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !"); } } return 1; }
CMD:setgodmode(playerid,params[])
{
// outside
new godmode[MAX_PLAYERS];
//inside the CMD:
new ID;
if(PlayerInfo[playerid][Admin] >= 2)
{
if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]");
if(godmode[playerid] == 0)
{
godmode[playerid] = 1;
SetPlayerHealth(ID, 10000000);
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !");
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !");
}
else
{
godmode[playerid] = 0;
SetPlayerHealth(ID, 100);
SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
}
}
else
{
SendClientMessage(playerid, -1, "{FF0000}You're not authorized to use this command{15FF00}!");
}
return 1;
}
if(PlayerInfo[playerid][Admin] >= 2)