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