Auto Godmode

Started by simpler
18/11/2008 18:03
Page 1 of 1
simpler18/11/2008 18:03

Hi!
So i tried to make a plugin that gives every player godmode when they spawn, i came up with this piece of code:


#include
#include
#include

#define PLUGIN "Auto Godmode"
#define AUTHOR "Phenom"
#define VERSION "1.0"

new amx_autogodmode

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
amx_autogodmode = register_cvar("amx_autogodmode", "1")
RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1)
}
public PlayerSpawn(id)
{
new maxPlayers = get_maxplayers();

for (new i=0; i
if (is_user_alive(i))
{

if(get_pcvar_num(amx_autogodmode ==1) && get_user_godmode(i) == 0)
{

set_user_godmode(i,1)
client_print(i, print_chat, "[Auto Godmode] You now got godmode")

}
}
}


It compiles just fine and it runs on the server but it ain't giving anyone godmode nor showing the message it's suppose to do.. Please tell me what's wrong // Phenom

xPaw mapper18/11/2008 18:32(edited 18/11/2008 18:33)

your spawn function should be like this

public PlayerSpawn(id) {
if(get_pcvar_num(amx_autogodmode == 1) && get_user_godmode(i) == 0) {
set_user_godmode(id, 1);
client_print(id, print_chat, "[Auto Godmode] Now you have godmode.");
}
}

simpler18/11/2008 18:56

xPaw it still don't works .. :S
Im confused, please help!

Lt.RAT18/11/2008 20:43(edited 18/11/2008 20:47)

1) look at "get_pcvar_num(amx_autogodmode == 1)" it returns wrong data :) should be "get_pcvar_num(amx_autogodmode) == 1"


2) correct for statement should be "for( i = 1; i <= maxplayers; i++ )" coz (i = 0) - worldspawn, so in your plugin latest player never get godmode theoretically (never test it and never test that for for described thing, but in all plugins i c used that for statement that deal with players)

simpler18/11/2008 21:13

Thnx for tip Lt.RAT, maybe my plugin will run thanks to you to guys :D

SchlumPF18/11/2008 21:20

rat was faster than me :(

simpler18/11/2008 21:23(edited 18/11/2008 21:24)

Well thanx anyways SchlumPF, happy you wanted to help me :D

Page 1 of 1

Please log in to post replies.