AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Action on spawn (https://forums.alliedmods.net/showthread.php?t=172897)

ingmar13 11-27-2011 08:28

Action on spawn
 
how to perform godmode ON on spawn?

i have this code.. but i'm not that good to fix that :<

PHP Code:

#include <amxmodx>
#include <fun>

#define PLUGIN_NAME    "mGodmode"
#define PLUGIN_VERSION    "1.0"
#define PLUGIN_AUTHOR    "Malle"

const FLAG_GODMODE = (<< 0);

new 
g_iFlags[33];
new const 
sPrename[] = "[mGod]";

public 
plugin_init( )
{
    
register_plugin"mGodmode""1.0""Malle" )
    
register_clcmd"say /god""cmdgod" )
    
register_clcmd"say /godmode""cmdgod" )
}

public 
client_disconnect(iPlayer)
{
    
g_iFlags[iPlayer] = 0;
}

public 
cmdgodid )
{
    new const 
sPrename[] = "[mGod]";
    
g_iFlags[id] ^= FLAG_GODMODE;
    
    
client_printidprint_chat"%s Yo DAWG you turned your godmode: %s",sPrenameg_iFlagsid ] & FLAG_GODMODE "On" "Off" );
    
    
set_user_godmodeid, !!( g_iFlagsid ] & FLAG_GODMODE) );
    
    return 
PLUGIN_HANDLED;



Napoleon_be 11-27-2011 09:32

Re: Action on spawn
 
PHP Code:

RegisterHam(Ham_Spawn"player""fwd_spawn"1

PHP Code:

public fwd_spawn(id) {
        
set_user_godmode(id)


Add this into your code, and it should work.

Devil259 11-27-2011 11:57

Re: Action on spawn
 
Don't forget to check if the player is alive.

Napoleon_be 11-27-2011 13:39

Re: Action on spawn
 
Quote:

Originally Posted by Devil259 (Post 1603630)
Don't forget to check if the player is alive.

He probably won't die in 0.1 seconds if he spawns right?

nikhilgupta345 11-27-2011 13:50

Re: Action on spawn
 
Quote:

Originally Posted by Napoleon_be (Post 1603573)
PHP Code:

RegisterHam(Ham_Spawn"player""fwd_spawn"1

PHP Code:

public fwd_spawn(id) {
        
set_user_godmode(id)


Add this into your code, and it should work.

set_user_godmode( id )

should be

set_user_godmode( id, 1 );


Your way will disable godmode. You need to set the flag to 1 so that it sets it to enabled. The second parameter defaults to disabled, so just leaving it blank will turn off godmode.

drekes 11-27-2011 14:03

Re: Action on spawn
 
Quote:

Originally Posted by Napoleon_be (Post 1603691)
He probably won't die in 0.1 seconds if he spawns right?

Ham_Spawn in called when the player is connecting too and he is not alive while connecting.

Napoleon_be 11-27-2011 14:46

Re: Action on spawn
 
Quote:

Originally Posted by drekes (Post 1603714)
Ham_Spawn in called when the player is connecting too and he is not alive while connecting.

If he's connecting, he will not be spawned..

Devil259 11-27-2011 14:59

Re: Action on spawn
 
From ham_const.inc
Code:

* Description:        This is typically called whenever an entity is created.
You have to check if user is alive..

drekes 11-27-2011 16:07

Re: Action on spawn
 
Quote:

Originally Posted by Napoleon_be (Post 1603748)
If he's connecting, he will not be spawned..

Why can't you just accept things like they are ?
Test it. You'll see that it gets called before you spawn too. That's why everybody does it.

EDIT: I never said he was gonna spawn when he connects. I said Ham_Spawn is also called when a player connects.
Doing stuff when he's not alive can throw runtime errors or even crash the server.

nikhilgupta345 11-27-2011 16:11

Re: Action on spawn
 
@Napolean: Like somebody says to you in almost every thread you post that you try to help people, Don't try to help people if you don't know what you're doing.


All times are GMT -4. The time now is 17:23.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.