For some reason this won't write a file...
From amx_climb_timer.
Code:
public read_button_locs() {
for( new i = 0 ; i < 3; ++i ) {
start_loc[i] = 0
stop_loc[i] = 0
}
new pathname[128]
get_cvar_string("amx_climbtimer_path",pathname,127)
new mapname[64]
get_mapname(mapname,63)
new filename[128]
format(filename, 127, "%s/%s.txt", pathname, mapname)
if( file_exists(filename) ) {
new number[192], line = 0, txtsize = 0
for( new i = 0 ; i < 3; i++ ) {
if( (line=read_file(filename,line,number,191,txtsize))!=0 )
start_loc[i] = str_to_num( number )
else {
locs_set = 0
return PLUGIN_HANDLED
}
}
for( new i = 0 ; i < 3; i++ ) {
if( (line=read_file(filename,line,number,191,txtsize))!=0 )
stop_loc[i] = str_to_num( number )
else {
locs_set = 0
return PLUGIN_HANDLED
}
}
locs_set = 1
}
else {
locs_set = 0
}
return PLUGIN_HANDLED
}
Code:
public save_button_locs( id ) {
if( start_loc[0] == 0 && start_loc[1] == 0 && start_loc[2] == 0 ) {
client_print(id,print_chat,"[%s] Can't save locs! Start loc are not set.", ct_pluginname )
return PLUGIN_HANDLED
}
if( stop_loc[0] == 0 && stop_loc[1] == 0 && stop_loc[2] == 0 ) {
client_print(id,print_chat,"[%s] Can't save locs! Stop loc are not set.", ct_pluginname )
return PLUGIN_HANDLED
}
new pathname[128]
get_cvar_string("amx_climbtimer_path",pathname,127)
new mapname[64]
get_mapname(mapname,63)
new filename[128]
format(filename, 127, "%s/%s.txt", pathname, mapname)
if( file_exists(filename) )
delete_file(filename)
for( new i = 0 ; i < 3; i++ ) {
new number[192]
num_to_str(start_loc[i],number,191)
write_file(filename, number)
}
for( new i = 0 ; i < 3; i++ ) {
new number[192]
num_to_str(stop_loc[i],number,191)
write_file(filename, number)
}
client_print(id,print_chat,"[%s] Start and stop loc are saved.", ct_pluginname )
set_user_gravity(id, 1.0)
client_print(id,print_chat,"[%s] Your gravity has been set to normal.", ct_pluginname )
return PLUGIN_HANDLED
}