[Half-Life AMXX] / kz_rewards.sma Repository:
ViewVC logotype

Annotation of /kz_rewards.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /*
2 :     KZ Rewards
3 :     Copyright (C) 2006-2007 Ian (Juan) Cammarata
4 :    
5 :     This program is free software; you can redistribute it and/or modify it under
6 :     the terms of the GNU General Public License as published by the Free Software
7 :     Foundation; either version 2 of the License, or (at your option) any later
8 :     version.
9 :    
10 :     This program is distributed in the hope that it will be useful, but WITHOUT ANY
11 :     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 :     PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 :    
14 :     You should have received a copy of the GNU General Public License along with
15 :     this program; go to http://www.opensource.org/licenses/gpl-license.php
16 :     */
17 :    
18 :     #include <amxmodx>
19 :     #include <amxmisc>
20 :     #include <engine>
21 :    
22 :     #define VERSION "0.2"
23 :     #define SF_MAX 50
24 :     #define SF_STRLEN 50
25 :    
26 :     new sfactions[SF_MAX][50], sfcount = 0
27 :     new p_enabled
28 :    
29 :     public plugin_init( )
30 :     {
31 :     register_plugin( "KZ Rewards", VERSION, "Ian Cammarata" )
32 :     register_cvar( "kz_rewards_version", VERSION, FCVAR_SERVER )
33 :    
34 :     p_enabled = register_cvar( "kzrw_enabled", "1" )
35 :    
36 :     //Load Start/Finish Commands
37 :     new ini[50]
38 :     get_configsdir( ini, 49 )
39 :     format( ini, 49, "%s/kz_rewards.ini", ini )
40 :     if( file_exists( ini ) )
41 :     {
42 :     new line = 0, text[SF_STRLEN], len
43 :     while( read_file( ini, line++, text, SF_STRLEN-1 , len ) )
44 :     {
45 :     if( !equal( text, ";", 1 ) && !equal( text, "#", 1 ) && !equal( text, "//", 2 ) )
46 :     {
47 :     if( sfcount < SF_MAX )
48 :     {
49 :     sfactions[sfcount] = text
50 :     sfcount++
51 :     }
52 :     }
53 :     }
54 :     }
55 :    
56 :     server_print( "[KZ Rewards] Loaded %d rewards from file.", sfcount )
57 :    
58 :     return PLUGIN_CONTINUE
59 :     }
60 :    
61 :     public client_PreThink( id )
62 :     {
63 :     if( is_user_alive( id ) && get_pcvar_num( p_enabled ) )
64 :     {
65 :     if( get_user_button(id) & IN_USE && !( get_user_oldbutton( id ) & IN_USE ) )
66 :     {//Detect button use. Replicated from HL SDK
67 :     new entlist[3], count
68 :     count = find_sphere_class( id, "func_button", 64.0, entlist, 3 )
69 :     if( count )
70 :     {
71 :     new Float:orig[3]
72 :     for( new i=0; i < count; i++ )
73 :     {
74 :     get_brush_entity_origin( entlist[i], orig )
75 :     if( is_in_viewcone( id, orig ) ) button_used( id, entlist[i] )
76 :     }
77 :     }
78 :     }
79 :     }
80 :    
81 :     return PLUGIN_CONTINUE
82 :     }
83 :    
84 :     public button_used( id, button )
85 :     {
86 :     new targ[32]
87 :     entity_get_string(button,EV_SZ_target,targ,32)
88 :    
89 :     if( equal( targ,"counter_start" ) || equal( targ, "clockstartbutton" ) || equal( targ, "firsttimerelay" ) )
90 :     sfexec( id, 0 )
91 :     else if( equal( targ, "counter_off" ) || equal( targ, "clockstopbutton" ) || equal( targ, "clockstop" ) )
92 :     sfexec( id, 1 )
93 :     }
94 :    
95 :     public sfexec( id, clevent )
96 :     {
97 :     new clstat[3]
98 :    
99 :     if( clevent == 0 ) clstat="st"
100 :     else clstat="fn"
101 :    
102 :     for( new i=0; i < sfcount; i++ )
103 :     {
104 :     new cmdstat[3], cmdtype[3], cmd[60], idtype[5]
105 :     parse( sfactions[i], cmdstat, 2, cmdtype, 2, cmd, sizeof(cmd)-1, idtype, 4 )
106 :     if( equali( cmdstat, clstat ) )
107 :     {
108 :     if( equali( cmdtype, "sc" ) )
109 :     {
110 :     if( equali( idtype, "uid" ) ) format( cmd, sizeof( cmd )-1, cmd, get_user_userid( id ) )
111 :     else
112 :     {
113 :     new name[24]
114 :     get_user_name( id, name, sizeof( name )-1 )
115 :     format( name, sizeof( name ), "^"%s^"", name )
116 :     format( cmd, sizeof( cmd )-1, cmd, name )
117 :     client_print( id, print_chat, cmd )
118 :     }
119 :     server_cmd( cmd )
120 :     }
121 :     else client_cmd( id, cmd )
122 :     }
123 :     }
124 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4