06.03.2014, 21:50
How can i make a /god command for players? usinz ZCMD
new GodMode[MAX_PLAYERS]; CMD:god(playerid, params[]) { SetPlayerHealth(playerid, 99999); GodMode[playerid] = true; }
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if(GodMode[playerid] == true) return 0; }
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) { if(GodMode[playerid] == true) return 0; }
if(!IsPlayerAdmin(playerid)) return 0;
new Godmode[MAX_PLAYERS];
Godmode[playerid] = 0;
CMD:god(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
{
if(Godmode[playerid] == 0)
{
Godmode[playerid] = 1;
SetPlayerHealth(playerid, 99999);
SetPlayerArmour(playerid, 99999);
SendClientMessage(playerid, -1, "You have enabled the god mode");
}
if(Godmode[playerid] == 1)
{
Godmode[playerid] = 0;
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SendClientMessage(playerid, -1, "You have disabled the god mode");
}
}
else
{
SendClientMessage(playerid, -1, "You are not an admin");
}
return 1;
}
CMD:god(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(Godmode[playerid] == 0)
{
Godmode[playerid] = 1;
SetPlayerHealth(playerid, 99999);
SetPlayerArmour(playerid, 99999);
SendClientMessage(playerid, -1, "You have enabled the god mode");
}
if(Godmode[playerid] == 1)
{
Godmode[playerid] = 0;
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SendClientMessage(playerid, -1, "You have disabled the god mode");
}
}
else
{
SendClientMessage(playerid, -1, "You are not logged in");
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(Godmode[playerid] == 1) return 0;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(Godmode[playerid] == 1) return 0;
}
i have made this now:
first of all add this near the other enums and news: pawn Код:
pawn Код:
if you want the command only for admins: pawn Код:
pawn Код:
0.3z pawn Код:
pawn Код:
|
CMD:godon(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
{
Godmode[playerid] = 1;
SetPlayerHealth(playerid, 99999);
SetPlayerArmour(playerid, 99999);
SendClientMessage(playerid, -1, "You have enabled the god mode");
return 1;
}
else
{
SendClientMessage(playerid, -1, "You are not an admin");
}
return 1;
}
CMD:godoff(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1 && IsPlayerConnected(playerid))
{
Godmode[playerid] = 0;
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SendClientMessage(playerid, -1, "You have disabled the god mode");
return 1;
}
else
{
SendClientMessage(playerid, -1, "You are not an admin");
}
return 1;
}
pawn Код:
pawn Код:
|
new bool:GodModeActive[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
if(GodModeActive[playerid] ? SetPlayerHealth(playerid, (Float:0x7F800000)) : SetPlayerHealth(playerid, 100.0)) {}
return 1;
}
CMD:god(playerid, params[])
{
//if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You are not an admin."); //Change this to your admin variable.
//Uncomment the line above if you want to restrict this command to admins only.
if(GodModeActive[playerid])
{
GodModeActive[playerid] = false;
SendClientMessage(playerid, -1, "God mode disabled.");
SetPlayerHealth(playerid, 100.0);
}
else if(!GodModeActive[playerid])
{
GodModeActive[playerid] = true;
SendClientMessage(playerid, -1, "God mode activated.");
SetPlayerHealth(playerid,(Float:0x7F800000));
}
return 1;
}