Simple help me please Godmode
#1

hey guys i am trying a cmd like this:

pawn Код:
COMMAND:god(playerid, params[])
{
    if(Adminstrator[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You're not an Adminstrator!");
    SetPlayerHealth(playerid, INFINITY);
    SendClientMessage(playerid, 0x00FF00FF, "Godmode ON");
    }
    else
    {
    SetPlayerHealth(playerid, 100);
    SendClientMessage(playerid, 0xFF0000FF, "Godmode OFF");
    return 1;
}
and it gives me these errors

C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(423) : warning 209: function "cmd_god" should return a value
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(424) : error 010: invalid function or declaration
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(42 : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#2

pawn Код:
COMMAND:god(playerid, params[])
{
    if(Adminstrator[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You're not an Adminstrator!");
        SetPlayerHealth(playerid, INFINITY);
        SendClientMessage(playerid, 0x00FF00FF, "Godmode ON");
    }
    else
    {
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid, 0xFF0000FF, "Godmode OFF");
    }
    return 1;
}
Reply
#3

Same.

pawn Код:
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(421) : warning 217: loose indentation
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(423) : warning 209: function "cmd_god" should return a value
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(424) : error 010: invalid function or declaration
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(429) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Reply
#4

pawn Код:
COMMAND:god(playerid, params[])
{
    if(Administrator[playerid] == 1)
    {
            if(Godmode[playerid] == 0)
            {
                SetPlayerHealth(playerid, INFINITY);
                SendClientMessage(playerid, 0x00FF00FF, "Godmode ON");
            }
            else
            {
                SetPlayerHealth(playerid, 100);
                SendClientMessage(playerid, 0xFF0000FF, "Godmode OFF");            
            }
    } else return SendClientMessage(playerid, 0xFF0000FF, "You're not an Adminstrator!");
    return 1;
}
Reply
#5

Awesome

pawn Код:
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(422) : error 017: undefined symbol "Godmode"
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(422) : warning 215: expression has no effect
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(422) : error 001: expected token: ";", but found "]"
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(422) : error 029: invalid expression, assumed zero
C:\Users\Axme\Desktop\Freeroam server\gamemodes\Tw.pwn(422) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Lol
Reply
#6

Add Godmode[MAX_PLAYERS]; on top, Godmode[playerid] = 0; in OnplayerConnect...
Reply
#7

May god bless you it works finally.

I rate your help.

pawn Код:
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
Thanks very much.
Reply
#8

The code is weird.. ^_^

For such things, a "bool" var is good and has better performance.

pawn Код:
//Global Variable (On top of your script)
new bool:gGMEnabled[MAX_PLAYERS];

COMMAND:god(playerid, params[])
{
    if(Adminstrator[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You're not an Adminstrator!");

    if(!gGMEnabled[playerid])
    {
        SetPlayerHealth(playerid, INFINITY);
        SendClientMessage(playerid, 0x00FF00FF, "Godmode ON");
    } else {
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid, 0xFF0000FF, "Godmode OFF");
    }
    return 1;
}

//And add gGMEnabled[playerid] = false; on player connect/disconnect, as you wish.
EDIT: ahh, too late.. xD
Reply
#9

Don't use these Godmodes above! This is the right way to make a god command:

pawn Код:
//At top
#include <zcmd> //Credits to Zeex

new HasGod[MAX_PLAYERS];

public OnPlayerConnect(playerid) //This is a callback
{
    HasGod[playerid] = 0;
    return 1;
}
//Otside ANY callback
CMD:god(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(HasGod[playerid] == 0)
        {
            HasGod[playerid] = 1;
            SendClientMessage(playerid, -1, "God mode turned on!");
        }
        else if(HasGod[playerid] == 1)
        {
            HasGod[playerid] = 0;
            SendClientMessage(playerid, -1, "God mode turned off!");
        }
    }
    else return SendClientMessage(playerid, -1, "You are not an admin");
    return 1;
}

public OnPlayerUpdate(playerid) //this is a callback
{
    if(HasGod[playerid] == 1)
    {
        SetTimer("SetHealth", 100, true);
    }
    return 1;
}

forward SetHealth(playerid);
public SetHealth(playerid) //this is a callback
{
    SetPlayerHealth(playerid, 100);
    return 1;
}
The other god commands won't hold all the time, after some time, you will die. e.g. get shoot by a minigun would kill you after like 30 seconds or more. Mine can't kill you and it's infinity. The timer is to prevent possible lag, you can set it to 1 second so there's even lower chance to get lag.
Reply
#10

@samtey:

Try this once, you'll not use OnPlayerUpdate again:
pawn Код:
#define iFloat 0x107FFF

public OnPlayerSpawn( playerid )
{
    SetPlayerHealth( playerid, iFloat );
    return true;
}
Now try to explode/burn/hit/fall/drown/goto space/break the earth/ your health will stay full. (unless you get exploded in a car).

Script performance:
OnPlayerUpdate : Godmode: Bad/Heavy.
iFloat: Godmode: Perfect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)