Godmode Command Help[ZCMD]
#1

I am really new to this and what I am trying to make here is a toggle-able command. Basically what I want it to do is make it set there health extremely high (godmode on) and then if they typed the command again, it will set the players health back to normal. Can someone help me?

Quote:

CMD:godmode(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
if (health == 100)
{
SetPlayerHealth(playerid, 90000.0);
SendClientMessageToAll(0xFFFF00AA, "A player has enabled godmode!");
}
else if(health == 90000.0 )
{
SetPlayerHealth(playerid, 100.0);
SendClientMessageToAll(0xFFFF00AA, "A player has disabled godmode!");
}
return 1;
}

Reply
#2

pawn Код:
CMD:godmode(playerid, params[])
{
    if(GodMode[playerid] == 0)
    {
        SetPlayerHealth(playerid, HEALTHHERE);
    }
    else if(GodMode[playerid] == 1)
    {
        SetPlayerHealth(playerid, HEALTHHERE);
    }
    return 1;
}
add
Код:
new GodMode[MAX_PLAYERS];
to the top of your script.

NOT TESTED.

EDIT: Your's is kinda wrong, but I like your thinking

EDIT2: Also, under OnPlayerConnect add this;
Код:
GodMode[playerid] = 0;
Reply
#3

Yeah, the terminology of when things are executing on mine are EXTREMELY exact, I plan to change that after I see it is working.

EDIT: just tried what Ditch suggested and it didn't work - Godmode turned on, but it would not turn off.
Reply
#4

pawn Код:
#define INFINITY                (Float:0x7F800000)
new GodMode[MAX_PLAYERS];



CMD:godmode(playerid, params[])
{
    if(GodMode[playerid] == 0) //god mode not set, lets set it
    {
        SetPlayerHealth(playerid, INFINITY);    //set the health to infinity
        GodMode[playerid] = 1;    //set godmode to true
    }
    else if(GodMode[playerid] == 1) //god mode set .. lets unset it
    {
        SetPlayerHealth(playerid, 100.0);    //set health to 100%
        GodMode[playerid] = 0;    //set godmode to false
    }
    return 1;
}
this is kinda how i do it.

but without extra vars like this

pawn Код:
#define INFINITY                (Float:0x7F800000)
CMD:godmode(playerid, params[])
{
    new Float:health;
    GetPlayerHealth(playerid, health);
    if(health > 100.0) //god mode set .. lets unset it
    {
        SetPlayerHealth(playerid, 100.0);    //set health to 100%
    }
    else //god mode not set, lets set it  
    {
        SetPlayerHealth(playerid, INFINITY);    //set the health to infinity
    }
    return 1;
}
Reply
#5

Why did you post once in Script Request Thread and here ?

Also just some little edits and done
pawn Код:
CMD:godmode(playerid) {
    new
        Float: health
    ;
    GetPlayerHealth(playerid, health);

    if(health <= 100.0) {
        SetPlayerHealth(playerid, Float: 0x7F800000);
        SendClientMessageToAll(0xFFFF00FF, "A player has enabled godmode!");
    } else {
        SetPlayerHealth(playerid, 100.0);
        SendClientMessageToAll(0xFFFF00FF, "A player has disabled godmode!");
    }
    return true;
}
Reply
#6

Awesome, Jonny that worked.

Any idea how I could modify what ive done so that my global messages saying a player is using godmode/isnt using godmode can be changed to display the actual players name instead of just the word player?

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
Why did you post once in Script Request Thread and here ?

Also just some little edits and done
pawn Код:
CMD:godmode(playerid) {
    new
        Float: health
    ;
    GetPlayerHealth(playerid, health);

    if(health <= 100.0) {
        SetPlayerHealth(playerid, Float: 0x7F800000);
        SendClientMessageToAll(0xFFFF00FF, "A player has enabled godmode!");
    } else {
        SetPlayerHealth(playerid, 100.0);
        SendClientMessageToAll(0xFFFF00FF, "A player has disabled godmode!");
    }
    return true;
}
Sorry, I'll delete my post there :C
Reply
#7

Quote:
Originally Posted by Kurtis96z
Посмотреть сообщение
Awesome, Jonny that worked.

Any idea how I could modify what ive done so that my global messages saying a player is using godmode/isnt using godmode can be changed to display the actual players name instead of just the word player?



Sorry, I'll delete my post there :C
pawn Код:
#define INFINITY                (Float:0x7F800000)
new GodMode[MAX_PLAYERS];



CMD:godmode(playerid, params[])
{
    if(GodMode[playerid] == 0) //god mode not set, lets set it
    {
        SetPlayerHealth(playerid, INFINITY);    //set the health to infinity
        GodMode[playerid] = 1;    //set godmode to true
        SendClientMessageToAll(COLOR_RED, " An Admin is now in god mode!");
    }
    else if(GodMode[playerid] == 1) //god mode set .. lets unset it
    {
        SetPlayerHealth(playerid, 100.0);    //set health to 100%
        GodMode[playerid] = 0;    //set godmode to false
        SendClientMessageToAll(COLOR_RED, "An Admin is now in god mode!");
    }
    return 1;
}
Reply
#8

@Edward156
thats not even close to what they asked!!!


@OP
yes you use format
and getplayername

something like
pawn Код:
new strOut[50],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName);
format(strOut,50,"%s has enabled godmode!",pName);
SendClientMessageToAll(0xFFFF00AA, strOut);
Reply
#9

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
@Edward156
thats not even close to what they asked!!!


@OP
yes you use format
and getplayername

something like
pawn Код:
new strOut[50],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName);
format(strOut,50,"%s has enabled godmode!",pName);
SendClientMessageToAll(0xFFFF00AA, strOut);
Ok I have done what you are explaining in both parts and I got 2 warnings.

C:\Users\Kurtis\Desktop\GTA - San Andreas\Pawno\gamemodes\learning.pwn(48 : warning 202: number of arguments does not match definition
C:\Users\Kurtis\Desktop\GTA - San Andreas\Pawno\gamemodes\learning.pwn(497) : warning 202: number of arguments does not match definition

Why did I receive these? what can I do to fix.

Edit: Oh, its because I do not have pName defined anywhere as anything right?
Edit: Nevermind
Reply
#10

Quote:
Originally Posted by Kurtis96z
Посмотреть сообщение
Ok I have done what you are explaining in both parts and I got 2 warnings.

C:\Users\Kurtis\Desktop\GTA - San Andreas\Pawno\gamemodes\learning.pwn(48 : warning 202: number of arguments does not match definition
C:\Users\Kurtis\Desktop\GTA - San Andreas\Pawno\gamemodes\learning.pwn(497) : warning 202: number of arguments does not match definition

Why did I receive these? what can I do to fix.

Edit: Oh, its because I do not have pName defined anywhere as anything right?
No, pname is already there in the first line. It's just for example,

{Billy, Bobby, Bob} = 3 names - but in this case, they're not names
{Billy, Bobby, Bob, Bill} = 4 names - as you can see, that code is only allowing 3 names but I put four. It means the number of arguments (variables) do not fit the number of requested variables.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)