Raised This Month: $51 Target: $400
 12% 

who's the problem with client id from other function call?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wangningyu
Member
Join Date: Dec 2011
Location: China.GuangDong
Old 06-21-2015 , 16:57   who's the problem with client id from other function call?
Reply With Quote #1

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
static killer, victim, assister, headshot,weapon_id,weapon_itemID;
static String:weapon[33];
static String:weapon_itemid[33];

//PrintToServer("Event_PlayerDeath call");
if(GetClientTeam(GetClientOfUserId(GetEventIn t(event, "userid"))) != GetClientTeam(GetClientOfUserId(GetEventInt(e vent, "attacker"))))
{
killer = GetClientOfUserId(GetEventInt(event, "attacker"));
victim = GetClientOfUserId(GetEventInt(event, "userid"));
assister = GetClientOfUserId(GetEventInt(event, "assister"));

eventcall(killer,EVENT_KILL);
eventcall(victim,EVENT_DEATH);
}
}

public eventcall(client,eventType)
{
// this client value is not same as Event_PlayerDeath' killer or vicitim ??
// what's the problem ??
}



thans for your reply !
__________________
One Code , One Dream !

Last edited by wangningyu; 06-21-2015 at 16:57.
wangningyu is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-21-2015 , 19:22   Re: who's the problem with client id from other function call?
Reply With Quote #2

try this:
PHP Code:
public Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserID(event.GetInt("attacker")), victim GetClientOfUserID(event.GetInt("userid")), assister GetClientOfUserID(event.GetInt("assister"));
    if (!
IsClientInGame(attacker) || !IsClientInGame(victim) || attacker == victim || GetClientTeam(attacker) == GetClientTeam(victim))
        return 
Plugin_Continue;
    
EventCall(killerEVENT_KILL);
    
EventCall(victimEVENT_DEATH);
    return 
Plugin_Continue;
}

void EventCall(int clientint type)
{

__________________

Last edited by WildCard65; 06-21-2015 at 19:23.
WildCard65 is offline
wangningyu
Member
Join Date: Dec 2011
Location: China.GuangDong
Old 06-21-2015 , 21:30   Re: who's the problem with client id from other function call?
Reply With Quote #3

Quote:
Originally Posted by WildCard65 View Post
try this:
PHP Code:
public Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserID(event.GetInt("attacker")), victim GetClientOfUserID(event.GetInt("userid")), assister GetClientOfUserID(event.GetInt("assister"));
    if (!
IsClientInGame(attacker) || !IsClientInGame(victim) || attacker == victim || GetClientTeam(attacker) == GetClientTeam(victim))
        return 
Plugin_Continue;
    
EventCall(killerEVENT_KILL);
    
EventCall(victimEVENT_DEATH);
    return 
Plugin_Continue;
}

void EventCall(int clientint type)
{

thanks !

here use int variable to save id ,not static , because the static variable is a automatic adaptation ?
__________________
One Code , One Dream !
wangningyu is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-22-2015 , 06:55   Re: who's the problem with client id from other function call?
Reply With Quote #4

Quote:
Originally Posted by wangningyu View Post
thanks !

here use int variable to save id ,not static , because the static variable is a automatic adaptation ?
static keyword means the value is not deleted after the function is finished.

Look at the following 2 functions and sample output:
PHP Code:
stock Test(test 0)
{
    new 
lol//In new syntax, it should be: int lol
    
if (test != 0)
        
lol test;
    return 
lol;
}

stock Test2(test 0)
{
    static 
lol//Down here in new syntax: static int lol
    
if (test != 0)
        
lol test;
    return 
lol;
}

public 
OnPluginStart()
{
    
PrintToServer("Test output 1: %d"Test(5)); //Test output 1: 5
    
PrintToServer("Test output 2: %d"Test(0)); //Test output 2: 0
    
PrintToServer("Test2 output 1: %d"Test2(5)); //Test2 output 1: 5
    
PrintToServer("Test2 output 2: %d"Test2(0)); //Test2 output 2: 5

__________________

Last edited by WildCard65; 06-22-2015 at 06:58.
WildCard65 is offline
wangningyu
Member
Join Date: Dec 2011
Location: China.GuangDong
Old 06-22-2015 , 09:02   Re: who's the problem with client id from other function call?
Reply With Quote #5

Quote:
Originally Posted by WildCard65 View Post
static keyword means the value is not deleted after the function is finished.

Look at the following 2 functions and sample output:
PHP Code:
stock Test(test 0)
{
    new 
lol//In new syntax, it should be: int lol
    
if (test != 0)
        
lol test;
    return 
lol;
}

stock Test2(test 0)
{
    static 
lol//Down here in new syntax: static int lol
    
if (test != 0)
        
lol test;
    return 
lol;
}

public 
OnPluginStart()
{
    
PrintToServer("Test output 1: %d"Test(5)); //Test output 1: 5
    
PrintToServer("Test output 2: %d"Test(0)); //Test output 2: 0
    
PrintToServer("Test2 output 1: %d"Test2(5)); //Test2 output 1: 5
    
PrintToServer("Test2 output 2: %d"Test2(0)); //Test2 output 2: 5

Thank you very much!
__________________
One Code , One Dream !
wangningyu 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 01:27.


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