How can i make a /god command for players? -
Mckarlis - 06.03.2014
How can i make a /god command for players? usinz ZCMD
Re: How can i make a /god command for players? -
Abagail - 06.03.2014
You can do:
Код:
new GodMode[MAX_PLAYERS];
CMD:god(playerid, params[])
{
SetPlayerHealth(playerid, 99999);
GodMode[playerid] = true;
}
If your using 0.3z do:
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(GodMode[playerid] == true) return 0;
}
if using 0.3x or below:
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(GodMode[playerid] == true) return 0;
}
By returning 0 the player won't take the damage. They should never go below 99999 in health. Put:
Код:
if(!IsPlayerAdmin(playerid)) return 0;
If you want to restrict the command to admins(RCON).
Re: How can i make a /god command for players? -
XK - 06.03.2014
i have made this now:
first of all add this near the other enums and news:
pawn Код:
new Godmode[MAX_PLAYERS];
Under OnPlayerConnect
and the command:
if you want the command only for admins:
pawn Код:
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;
}
and for all of the players:
pawn Код:
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;
}
and under OnPlayerTakeDamage:
0.3z
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(Godmode[playerid] == 1) return 0;
}
0.3x:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(Godmode[playerid] == 1) return 0;
}
Re: How can i make a /god command for players? -
Mckarlis - 06.03.2014
Quote:
Originally Posted by XK
i have made this now:
first of all add this near the other enums and news:
pawn Код:
new Godmode[MAX_PLAYERS];
Under OnPlayerConnect
and the command:
if you want the command only for admins:
pawn Код:
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; }
and for all of the players:
pawn Код:
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; }
and under OnPlayerTakeDamage:
0.3z
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if(Godmode[playerid] == 1) return 0; }
0.3x:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) { if(Godmode[playerid] == 1) return 0; }
|
When i use /god a message shows up you have enabled god and under it you have disabled god
Re: How can i make a /god command for players? -
XK - 06.03.2014
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;
}
pawn Код:
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;
}
i have checked this code and it worked for me now
Re: How can i make a /god command for players? -
XK - 06.03.2014
and i have tested the first code that i wrote and it worked fine
Re: How can i make a /god command for players? -
Mckarlis - 06.03.2014
Quote:
Originally Posted by XK
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; }
pawn Код:
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; }
i have checked this code and it worked for me now
|
Thank you +REP
Re: How can i make a /god command for players? -
Threshold - 07.03.2014
For one /god command:
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;
}