[FilterScript] /god command for admins
#3

Quote:
Originally Posted by Bicentric
View Post
Nicely done

Instead of setting their health that that extremely high number, why not just set it to infinity?

pawn Code:
#if !defined FLOAT_INFINITY
    #define FLOAT_INFINITY   (Float:0x7F800000)
#endif
You are right buddy, here is the updated:
pawn Code:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
#define FLOAT_INFINITY (Float:0x7F800000)

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 infinity,
    //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, FLOAT_INFINITY);
        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, FLOAT_INFINITY);
            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;
}
Reply


Messages In This Thread
/god command for admins - by HurtLocker - 12.03.2013, 18:39
Re: /god command for admins - by Bicentric - 12.03.2013, 18:43
Re: /god command for admins - by HurtLocker - 12.03.2013, 18:52
Re: /god command for admins - by Private200 - 12.03.2013, 18:54
Re: /god command for admins - by HurtLocker - 12.03.2013, 18:58
Re: /god command for admins - by iGetty - 12.03.2013, 19:00
Re: /god command for admins - by Private200 - 13.03.2013, 18:24
Re: /god command for admins - by Djole1337 - 13.03.2013, 18:39
Re: /god command for admins - by HurtLocker - 14.03.2013, 21:33
Re: /god command for admins - by Djole1337 - 15.03.2013, 11:02

Forum Jump:


Users browsing this thread: 1 Guest(s)