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

[L4D2] Points Resetter


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
noxman
Member
Join Date: Jun 2012
Old 10-24-2013 , 10:40   [L4D2] Points Resetter
Reply With Quote #1

Hello,

i have this plugin: http://forums.alliedmods.net/showthread.php?p=1257852

i want include a point resetter. If a player change the team during the game, the points should be resettet (but only for this player, not whole Team). At the moment, the points will be reset at round_start and round_end only.

I coded something (myself):

Spoiler


But a hard bugg: The points are reset always (without teamchange too). What is wrong? Sry for my english.
noxman is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 10-24-2013 , 10:57   Re: [L4D2] Points Resetter
Reply With Quote #2

That does not make any sense
PHP Code:
if (teamold != teamnewclient
And you are clearing the whole array, that is why it points are being reset for each player.
Something like that will do
PHP Code:
public Action:Event_TeamChange(Handle:eventString:event_name[], bool:dontBroadcast) {

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
teamnew GetEventInt(event"team");
    new 
teamold GetEventInt(event"oldteam");

    if (
teamold != teamnew && IsAllowedReset()) {
        
points[client] = GetConVarInt(StartPoints);
        
hurtcount[client] = 0;
        
protectcount[client] = 0;
        
headshotcount[client] = 0;
        
killcount[client] = 0;
        
wassmoker[client] = 0;
    }
    
    
tanksspawned 0;
    
witchsspawned 0;
    
PrintToChat(client"[PS]The Points are been reset to 200.");

xf117 is offline
Send a message via ICQ to xf117
noxman
Member
Join Date: Jun 2012
Old 10-24-2013 , 14:34   Re: [L4D2] Points Resetter
Reply With Quote #3

Thank you. It works

Last edited by noxman; 10-24-2013 at 14:34.
noxman is offline
noxman
Member
Join Date: Jun 2012
Old 10-31-2013 , 19:18   Re: [L4D2] Points Resetter
Reply With Quote #4

It works, but it spams my console with a error:

PHP Code:
L 10/31/2013 19:15:32: [SMNative "PrintToChat" reportedClient index 0 is invalid
L 10
/31/2013 19:15:32: [SMDisplaying call stack trace for plugin "point_system_167_fix_reset_beta.smx":
L 10/31/2013 19:15:32: [SM]   [0]  Line 702point_system_167_fix_reset_beta.sp::Event_TeamChange()
L 10/31/2013 19:15:32: [SMNative "PrintToChat" reportedClient index 0 is invalid
L 10
/31/2013 19:15:32: [SMDisplaying call stack trace for plugin "point_system_167_fix_reset_beta.smx":
L 10/31/2013 19:15:32: [SM]   [0]  Line 702point_system_167_fix_reset_beta.sp::Event_TeamChange()
L 10/31/2013 19:15:32: [SMNative "PrintToChat" reportedClient index 0 is invalid
L 10
/31/2013 19:15:32: [SMDisplaying call stack trace for plugin "point_system_167_fix_reset_beta.smx":
L 10/31/2013 19:15:32: [SM]   [0]  Line 702point_system_167_fix_reset_beta.sp::Event_TeamChange()
L 10/31/2013 19:15:32: [SMNative "PrintToChat" reportedClient index 0 is invalid
L 10
/31/2013 19:15:32: [SMDisplaying call stack trace for plugin "point_system_167_fix_reset_beta.smx":
L 10/31/2013 19:15:32: [SM]   [0]  Line 702point_system_167_fix_reset_beta.sp::Event_TeamChange()
L 10/31/2013 19:15:32: [SMNative "PrintToChat" reportedClient index 0 is invalid
L 10
/31/2013 19:15:32: [SMDisplaying call stack trace for plugin "point_system_167_fix_reset_beta.smx":
L 10/31/2013 19:15:32: [SM]   [0]  Line 702point_system_167_fix_reset_beta.sp::Event_TeamChange()
L 10/31/2013 19:15:36: [SMNative "PrintToChat" reportedClient index 0 is invalid
L 10
/31/2013 19:15:36: [SMDisplaying call stack trace for plugin "point_system_167_fix_reset_beta.smx":
L 10/31/2013 19:15:36: [SM]   [0]  Line 702point_system_167_fix_reset_beta.sp::Event_TeamChange() 
noxman is offline
sdz
Senior Member
Join Date: Feb 2012
Old 10-31-2013 , 21:36   Re: [L4D2] Points Resetter
Reply With Quote #5

PHP Code:
public Action:Event_TeamChange(Handle:eventString:event_name[], bool:dontBroadcast) {

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
teamnew GetEventInt(event"team");
    new 
teamold GetEventInt(event"oldteam");

    if (
teamold != teamnew && IsAllowedReset()) {
        
points[client] = GetConVarInt(StartPoints);
        
hurtcount[client] = 0;
        
protectcount[client] = 0;
        
headshotcount[client] = 0;
        
killcount[client] = 0;
        
wassmoker[client] = 0;
    }
    
    
tanksspawned 0;
    
witchsspawned 0;
    if(
IsClientInGame(client))
        
PrintToChat(client"[PS]The Points are been reset to 200.");

Always want to check if the client is in game.
if(IsClientInGame(client))

Last edited by sdz; 10-31-2013 at 21:37.
sdz is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 11-01-2013 , 13:00   Re: [L4D2] Points Resetter
Reply With Quote #6

This will probably also yield an error, because 0 is not a valid client.
I'm not sure, how and why this event gets fired with client 0, but workaround is:
PHP Code:
public Action:Event_TeamChange(Handle:eventString:event_name[], bool:dontBroadcast) {

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
client == 0) {
        return 
Plugin_Continue;
    }
    
// The rest of the code is the same 
And with this is safe to add @EasSidezz's check for IsClientInGame.
xf117 is offline
Send a message via ICQ to xf117
noxman
Member
Join Date: Jun 2012
Old 11-02-2013 , 11:39   Re: [L4D2] Points Resetter
Reply With Quote #7

Quote:
Originally Posted by xf117 View Post
This will probably also yield an error, because 0 is not a valid client.
I'm not sure, how and why this event gets fired with client 0, but workaround is:
PHP Code:
public Action:Event_TeamChange(Handle:eventString:event_name[], bool:dontBroadcast) {

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
client == 0) {
        return 
Plugin_Continue;
    }
    
// The rest of the code is the same 
And with this is safe to add @EasSidezz's check for IsClientInGame.
Thanks for that, but i get a warning:


Last edited by noxman; 11-02-2013 at 11:40.
noxman is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-02-2013 , 11:47   Re: [L4D2] Points Resetter
Reply With Quote #8

Quote:
Originally Posted by noxman View Post
Thanks for that, but i get a warning:

PHP Code:
if ( client == ) return; 
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
noxman
Member
Join Date: Jun 2012
Old 11-02-2013 , 11:52   Re: [L4D2] Points Resetter
Reply With Quote #9

Wow, thanks
noxman is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 11-02-2013 , 16:42   Re: [L4D2] Points Resetter
Reply With Quote #10

It doesn't really matter what to return - the hook is in Post mode. I assumed you have
PHP Code:
 return Plugin_Continue
in the end of the callback. Didn't check that.
xf117 is offline
Send a message via ICQ to xf117
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 17:19.


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