12.03.2013, 18:39
(
Last edited by HurtLocker; 12/03/2013 at 09:20 PM.
)
A simple and useful command which allows you to manage gods in your server! I felt really good when I got it working. Oh yea.
EDIT: update: using infinity instead of 999~~ --> scroll down.
pawn Code:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
CMD:god(playerid, params[])
{
//new str3[128];
new str1[128], str2[128], admin[MAX_PLAYER_NAME], p[MAX_PLAYER_NAME], id, Float: health1, Float:health2;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command");
//Make yourself god by typing only: /god
GetPlayerHealth(playerid, health1);
//format(str3, sizeof(str3), "health: %f.", health1); With these lines I found out that if you set a player's health to 9999~~.0,
//SendClientMessage(playerid, COLOR_ORANGE, str3); his health value becomes actually 0.0 and so I got the code working, took me hours, damn.
if(sscanf(params, "d", id)) //do not change "d" with "u" or in /god [ID] format,
{ //you will receive message "ERROR: Player is not connected." even if you enter valid id.
if (health1==0.0)
{
SetPlayerHealth(playerid, 100.0);
return SendClientMessage(playerid,0x00FF00AA, "Back to mortality.");
}
if (health1>0.0)
{
SetPlayerHealth(playerid, 9999999999999999.0);
return SendClientMessage(playerid, 0x00FF00AA, "You are god now!");
}
}
//Make a player of your server god with /god [ID]
if(IsPlayerConnected(id))
{
GetPlayerName(playerid, admin, MAX_PLAYER_NAME);
GetPlayerName(id, p, MAX_PLAYER_NAME);
GetPlayerHealth(id, health2);
if (health2>0.0)
{
SetPlayerHealth(id, 9999999999999999.0);
format(str2, sizeof(str2), "You have successfully turned %s into god.", p);
SendClientMessage(playerid, 0x00FF00AA, str2);
format(str1, sizeof(str1), "Admin %s has turned you into god!", admin);
SendClientMessage(id, 0x00FF00AA, str1);
}
if (health2==0)
{
SetPlayerHealth(id, 100.0);
format(str2, sizeof(str2), "You have turned god %s into human.", p);
SendClientMessage(playerid, 0x00FF00AA, str2);
return SendClientMessage(id, 0x00FF00AA, "Back to mortality.");
}
}
else SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
return 1;
}