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

Newbie


Post New Thread Reply   
 
Thread Tools Display Modes
Alice Margatroid
Junior Member
Join Date: Sep 2012
Old 09-12-2012 , 08:42   Re: Newbie
Reply With Quote #11

if you have time commenting him, could you then do a proper version of this then :c?
Alice Margatroid is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 09-12-2012 , 10:56   Re: Newbie
Reply With Quote #12

PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "Health on spawn",
    
author "FaTony",
    
description "Changes client health on spawn",
    
version "1.0",
    
url ""
}

const 
SpawnHealth 120;

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}
    
public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntityHealth(clientSpawnHealth);

__________________

Last edited by FaTony; 09-12-2012 at 11:03.
FaTony is offline
Alice Margatroid
Junior Member
Join Date: Sep 2012
Old 09-12-2012 , 11:01   Re: Newbie
Reply With Quote #13

Quote:
Originally Posted by FaTony View Post
PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "Health on spawn",
    
author "FaTony",
    
description "Change Healt",
    
version "1.0",
    
url ""
}

const 
SpawnHealth 120;

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}
    
public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntityHealth(clientSpawnHealth);

thank you
Alice Margatroid is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 09-12-2012 , 16:12   Re: Newbie
Reply With Quote #14

Quote:
Originally Posted by FaTony View Post
PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "Health on spawn",
    
author "FaTony",
    
description "Changes client health on spawn",
    
version "1.0",
    
url ""
}

const 
SpawnHealth 120;

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}
    
public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntityHealth(clientSpawnHealth);

you use "new" and create a var everytime when a player spawn.. Unnecessay
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 09-12-2012 , 16:21   Re: Newbie
Reply With Quote #15

Quote:
Originally Posted by rak View Post
you use "new" and create a var everytime when a player spawn.. Unnecessay
It's only being deleted and recreated. The time it takes to create a variable is almost imperceptible compared to the rest of the script and the server's tens of other plugins. Not worth fussing over.
__________________
11530 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 09-12-2012 , 16:23   Re: Newbie
Reply With Quote #16

Quote:
Originally Posted by rak View Post
you use "new" and create a var everytime when a player spawn.. Unnecessay
What do u mean? What the different between static and new? I already read those in tutorial but don't understand?

Isn't that both always be created every time player spawn?

If u don't mind share some of your kung-fu please?

EDIT: well 11530 already respond..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 09-12-2012 at 16:24.
GsiX is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 09-12-2012 , 16:42   Re: Newbie
Reply With Quote #17

Quote:
Originally Posted by GsiX View Post
What do u mean? What the different between static and new? I already read those in tutorial but don't understand?

Isn't that both always be created every time player spawn?

If u don't mind share some of your kung-fu please?

EDIT: well 11530 already respond..
static is created 1 time and save the value in the memory.. is something like a global var in a specific function..

example

PHP Code:
#include <sourcemod>

public Plugin:myinfo = {    
    
name "Test Healt",     
    
author "[R]ak",     
    
description "Change Healt",     
    
version "1.0",     
    
url ""
}

const 
NEW_HEALT    127

public OnPluginStart()
    
HookEvent("player_spawn"Event_PlayerSpawn)

public 
Event_PlayerSpawn(Handle:Event, const String:name[], bool:dontBroadcast) {
    
    static 
idcheck_id
    
    
if(!id) {
        
        
id GetClientOfUserId(GetEventInt(Event"userid"))
        
        
SetEntityHealth(idNEW_HEALT)
                
    }
    else {
        
        
check_id GetClientOfUserId(GetEventInt(Event"userid"))
        
        if(
id == check_id)
            
SetEntityHealth(idNEW_HEALT)
        
    }

only the index in "id" have new healt
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 09-12-2012 at 16:44.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 09-12-2012 , 16:50   Re: Newbie
Reply With Quote #18

thanks, that example is clear as crystal.

No matter how many times the function called it will bypass the id once it contain value.

EDIT: Sorry more question.. if that so, can i call that id outside of the function if u say it was someting like global var?

EDIT: EDIT: never mind i didn't read carefully..

Quote:
Originally Posted by rak View Post
static is created 1 time and save the value in the memory.. is something like a global var in a specific function..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 09-12-2012 at 17:01.
GsiX is offline
Alice Margatroid
Junior Member
Join Date: Sep 2012
Old 09-12-2012 , 19:54   Re: Newbie
Reply With Quote #19

im confused :c ...

which do i go by :c?
Alice Margatroid is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 09-12-2012 , 20:04   Re: Newbie
Reply With Quote #20

confused of which? If related to my post... well someday u will understand but for now just ignore it.

As a beginner like me, u take example from FaTony.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 09-12-2012 at 20:07.
GsiX is offline
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 19:55.


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