Raised This Month: $32 Target: $400
 8% 

Action on spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ingmar13
Member
Join Date: Jun 2008
Old 11-27-2011 , 08:28   Action on spawn
Reply With Quote #1

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;

__________________
will make maps for food!
ingmar13 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-27-2011 , 09:32   Re: Action on spawn
Reply With Quote #2

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.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 11-27-2011 , 11:57   Re: Action on spawn
Reply With Quote #3

Don't forget to check if the player is alive.
Devil259 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-27-2011 , 13:39   Re: Action on spawn
Reply With Quote #4

Quote:
Originally Posted by Devil259 View Post
Don't forget to check if the player is alive.
He probably won't die in 0.1 seconds if he spawns right?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 11-27-2011 , 13:50   Re: Action on spawn
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
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.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-27-2011 , 14:03   Re: Action on spawn
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
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.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-27-2011 , 14:46   Re: Action on spawn
Reply With Quote #7

Quote:
Originally Posted by drekes View Post
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..
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 11-27-2011 , 14:59   Re: Action on spawn
Reply With Quote #8

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

Last edited by Devil259; 11-27-2011 at 15:00.
Devil259 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-27-2011 , 16:07   Re: Action on spawn
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
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.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 11-27-2011 at 16:09.
drekes is offline
Send a message via MSN to drekes
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 11-27-2011 , 16:11   Re: Action on spawn
Reply With Quote #10

@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.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:32.


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