Quote:
Originally Posted by billy1337samp
original:
PHP Code:
CMD:god(playerid)
{
if (!IsPlayerAdmin(playerid) && p_Account[playerid][E_ACCOUNT_ADMIN_LEVEL] < 1)
return SendClientMessage(playerid, COLOR_TOMATO, "Error: Only admin level 1 and above have access to this command.");
if (!p_Data[playerid][E_PDATA_GODMODE])
{
SetPlayerHealth(playerid, FLOAT_INFINITY);
GameTextForPlayer(playerid, "~g~Godmode on", 5000, 3);
}
else
{
SetPlayerHealth(playerid, 100.0);
GameTextForPlayer(playerid, "~r~Godmode off", 5000, 3);
}
p_Data[playerid][E_PDATA_GODMODE] = !p_Data[playerid][E_PDATA_GODMODE];
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
return 1;
}
I don't know why but some admins may want to do the way I want to... If admin health = 20.00 and does /god then /god off, then their health will be 100.00. If you want the admins health to return back to 20.00 (or whatever amount it was) then use this where it says CMD:god(playerid)
PHP Code:
CMD:god(playerid)
{
new Float:oldHealth[MAX_PLAYERS];
if (!IsPlayerAdmin(playerid) && p_Account[playerid][E_ACCOUNT_ADMIN_LEVEL] < 1)
return SendClientMessage(playerid, COLOR_TOMATO, "Error: Only admin level 1 and above have access to this command.");
if (!p_Data[playerid][E_PDATA_GODMODE])
{
GetPlayerHealth(playerid, oldHealth[playerid]);
SetPlayerHealth(playerid, FLOAT_INFINITY);
GameTextForPlayer(playerid, "~g~Godmode on", 5000, 3);
}
else
{
SetPlayerHealth(playerid, oldHealth[playerid]);
GameTextForPlayer(playerid, "~r~Godmode off", 5000, 3);
}
p_Data[playerid][E_PDATA_GODMODE] = !p_Data[playerid][E_PDATA_GODMODE];
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
return 1;
}
basically grabs player health before it gets INFINITE and then after god mode is off it returns original health.
|
This will actually kill when you yurn off godmode!
Either make the variable global or put "static Float
ldHealth[MAX_PLAYERS];" instead of "new Float
ldHealth[MAX_PLAYERS];"