Godmode only when admin
#1

Hi guys!

I'm trying to create a godmode script, the godmode may only activate if the player is RCON admin.

But I'm doing something wrong, can someone tell me whats wrong with my code?

Код:
CMD:god(playerid, params[]) //Line 88
		if(!IsPlayerAdmin(playerid))
	{
		SendClientMessage(playerid,0xFF0000AA,"Mag jij niet!.");
		return 1;
	}
    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
        SendClientMessage(playerid, 0xFF0000FF, "Godmode aan");
    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
        SendClientMessage(playerid, 0xFF0000FF, "Godmode uit");
    return 1; //Line 104
}
Error I'm getting:
Код:
god.pwn(88) : error 010: invalid function or declaration
god.pwn(88 -- 99) : error 010: invalid function or declaration
god.pwn(88 -- 104) : error 010: invalid function or declaration
god.pwn(88 -- 104) : fatal error 107: too many error messages on one line
Thanks!
Reply
#2

Before:

PHP код:
CMD:god(playeridparams[]) //Line 88
        
if(!IsPlayerAdmin(playerid))
    {
        
SendClientMessage(playerid,0xFF0000AA,"Mag jij niet!.");
        return 
1;
    }
    if(
GodMode[playerid] == 0//god mode not set, lets set it
    
}
        
SetPlayerHealth(playeridINFINITY);    //set the health to infinity
        
GodMode[playerid] = 1;    //set godmode to true
        
SendClientMessage(playerid0xFF0000FF"Godmode aan");
    else if(
GodMode[playerid] == 1//god mode set .. lets unset it
    
}
        
SetPlayerHealth(playerid100.0);    //set health to 100%
        
GodMode[playerid] = 0;    //set godmode to false
        
SendClientMessage(playerid0xFF0000FF"Godmode uit");
    return 
1//Line 104

After:

PHP код:
CMD:god(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Mag jij niet!.");
    if(
GodMode[playerid] == 0//god mode not set, lets set it
    
{
        
SetPlayerHealth(playeridINFINITY);    //set the health to infinity
        
GodMode[playerid] = 1;    //set godmode to true
        
SendClientMessage(playerid0xFF0000FF"Godmode aan");
    }
    else if(
GodMode[playerid] == 1//god mode set .. lets unset it
    
{
        
SetPlayerHealth(playerid100.0);    //set health to 100%
        
GodMode[playerid] = 0;    //set godmode to false
        
SendClientMessage(playerid0xFF0000FF"Godmode uit");
    }
    return 
1;

You should learn how to ident your codes.
Reply
#3

PHP код:

CMD
:god(playeridparams[]) 

    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,RED"Mag jij niet!."); 
    if(
GodMode[playerid] == 1// in case 1 when it will be actived :
    

        
SetPlayerHealth(playerid9999); // in infinity case you'll need to define so amx was right 
        
SetplayerArmour(playerid9999); // set $s player armour !!!!
        
GodMode[playerid] = 1;    //set the %s player godmode
        
SendClientMessage(playerid0xFF0000FF"Godmode aan"); 
    } 
    else if(
GodMode[playerid] == 0// in case 0 when it will be un-activated :
    

        
SetPlayerHealth(playerid100.0);    //set health to 100% 
        
SetPlayerArmour(playerid100.0); // some new funtion
        
GodMode[playerid] = 0;    
        
SendClientMessage(playerid0xFF0000FF"Godmode uit"); 
        return 
1// gtakiller your returning funtion was wronge too
    
}

Try this and gta killer this
PHP код:
f(GodMode[playerid] == 1
If activated so do blah blah blah not if 0
ONTOPIC: Asker, Only rcon admin can use this but if you want dor admins mean lvl admin so you should replace this
PHP код:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,RED"Mag jij niet!."); 
PHP код:
if(!IsPlayerAdmin(playerid) == 3) return SendClientMessage(playerid,RED"Mag jij niet!."); 
Reply
#4

You have to include zcmd.inc which you can download from:
https://sampforum.blast.hk/showthread.php?tid=91354

And yea replace it with this:

You forgot some { and } very important to look at those things when you are scripting.


[QUOTE=gtakillerIV;2164430]Before:

PHP код:
CMD:god(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Mag jij niet!.");
    if(
GodMode[playerid] == 0//god mode not set, lets set it
    
{
        
SetPlayerHealth(playeridINFINITY);    //set the health to infinity
        
GodMode[playerid] = 1;    //set godmode to true
        
SendClientMessage(playerid0xFF0000FF"Godmode aan");
    }
    else if(
GodMode[playerid] == 1//god mode set .. lets unset it
    
{
        
SetPlayerHealth(playerid100.0);    //set health to 100%
        
GodMode[playerid] = 0;    //set godmode to false
        
SendClientMessage(playerid0xFF0000FF"Godmode uit");
    }
    return 
1;

QUOTE]
Reply
#5

Quote:
Originally Posted by мυ∂υℓ_вacнα
Посмотреть сообщение
PHP код:

CMD
:god(playeridparams[]) //Line 88
{
    if(!
IsPlayerAdmin(playerid))
        {
             
SendClientMessage(playerid,0xFF0000AA,"Mag jij niet!.");
        }   
        
SetPlayerHealth(playeridINFINITY);    //set the health to infinity
        
GodMode[playerid] = 1;    //set godmode to true
        
SendClientMessage(playerid0xFF0000FF"Godmode ACtivated !!");
    else if(
GodMode[playerid] == 1//god mode set .. lets unset it
    
}
        
SetPlayerHealth(playerid100.0);    //set health to 100%
        
GodMode[playerid] = 0;    //set godmode to false
        
SendClientMessage(playerid0xFF0000FF"Godmode uit");
    return 
1//Line 104

Try this !!!
Wrong!

Look at myne and you will see that you are wrong..

@Roel: No error says that he didin't include it..
Reply
#6

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
Wrong!

Look at myne and you will see that you are wrong..

@Roel: No error says that he didin't include it..
BY mistake the SUBMITE button was pressed any way ... both work = 1 . Still 1 function was wronge =
Reply
#7

an easy way for it :
PHP код:
SetPlayerHealth(playerid,999999); //makes player godmode 
Reply
#8

god.pwn(8 : error 010: invalid function or declaration

It doesn't says anything about the { or } because he doesn't read it because he get stuck at the :god , so I guess he didn't included zcmd, but yea he also should use your code after he included it.
Reply
#9

Quote:
Originally Posted by Roel
Посмотреть сообщение
god.pwn(8 : error 010: invalid function or declaration

It doesn't says anything about the { or } because he doesn't read it because he get stuck at the :god , so I guess he didn't included zcmd, but yea he also should use your code after he included it.
Check my edit : This all error will be fixed after correcting the wronge code :
Reply
#10

Quote:
Originally Posted by мυ∂υℓ_вacнα
Посмотреть сообщение
Check my edit : This all error will be fixed after correcting the wronge code :
No it will make it worse, wtf is this?

pawn Код:
if(!IsPlayerAdmin(playerid) == 3) return SendClientMessage(playerid,RED"Mag jij niet!.");
This will never work, IsPlayerAdmin only returns true or false, there are no rcon levels, you need a admin system for this.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)