Raised This Month: $ Target: $400
 0% 

Problems with getting data/setting data


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 01-16-2006 , 14:37  
Reply With Quote #10

Recent untested version:

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define TEAM_T 1 #define TEAM_CT 2 public plugin_init()     {     register_plugin("Easy Plugin Tester", ".9b", "slmclarengt(sleeper)")     register_concmd("amx_testplugin", "testPlugin", ADMIN_BAN, "Saves money, team & map to be reverted") } public testPlugin(id)     {       new map[64]     get_mapname(map, 63)         new directory[60]     get_configsdir(directory, 59)         new info[400]     new authid[32], money[32], teams[3], names[33][32], frags[128], deaths[128]         console_print(0, "DEBUG 'tester - testPlugin': Phase 1: Variables - Passed")         for (new a = 1; a <= get_playersnum(); a++)         {         get_user_team(a, teams[a], 2) // get team         get_user_authid(a, authid[a], 31) // get authid         money[a] = cs_get_user_money(a) // save the money of index 'a' player         get_user_name(a, names[a], 32) // initialize names[a] to user's name         frags[a] = get_user_frags(a) // get frags         deaths[a] = get_user_deaths(a)// get deaths                 // format to message - starts with: name, authid, money, team         format(info, 399, "%s %s %d %s %d %d", names[a], authid[a], money[a], teams[a], frags[a], deaths[a])                 // write the data stored in array info into data.txt to be read later         write_file("%s/data.txt", info)     }     // debug prints     console_print(0, "DEBUG 'tester - testPlugin': Phase 2: After for loop - Passed")     console_print(0, "%s is the config directory", directory)         set_task(15.0,"changemap()",0) // change map in 15 seconds!         client_print(0, print_chat, "Money/team/map have been saved - changing map and reverting back")     client_print(0, print_chat, "Map is changing back to %s in 15 seconds!", map)         set_task(45.0, "revertBack(id)", 0) // call "revertBack" in 45 seconds!         return PLUGIN_CONTINUE } public changemap()     {     new map[64]     get_mapname(map, 63)         server_cmd("changelevel %s", map) } public revertBack(id)     {     new directory[60]     get_configsdir(directory, 59)         new authid[32], money[32], teams[3], names[33][32], frags[128], deaths[128]         console_print(0, "DEBUG 'tester - revertBack': Phase 1: Variables - Passed")         for( new i = 1; i <= get_playersnum(); i++ )         {         // I don't know why I even put this stuff here         // forgot comments to explain why I need this...         // I do not think I need this         /*         get_user_team(i, teams[i], 2) // save teams         get_user_authid(i, authid[i], 31) // get authid         money[i] = cs_get_user_money(i) // save the money of index i player         frags[i] = get_user_frags(i) // save frags         deaths[i] = get_user_deaths(i) // save deaths         */                 read_file("%s/data.txt", i, names[i], 32, names[i+1][i]) // read/save         read_file("%s/data.txt", i, authid[i], 31, authid[i]) // read/save         read_file("%s/data.txt", i, money[i], 31, money[i]) // read/save         read_file("%s/data.txt", i, teams[i], 2, teams[i]) // read/save         read_file("%s/data.txt", i, frags[i], 127, frags[i]) // read/save         read_file("%s/data.txt", i, deaths[i], 127, deaths[i]) // read/save                 while (is_user_connected(i) == 1)             {             while (get_user_team(i) == TEAM_CT || get_user_team(i) == TEAM_T)                 {                 //set their info back                 cs_set_user_team(i, teams[i])                 cs_set_user_deaths(i, deaths[i])                 set_user_frags(i, frags[i])                 cs_set_user_money(i, money[i], 1)                                 set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)                 show_hudmessage(id, "Your Money/Team/Frags/Death have been restored!")                                   if (get_user_team(i) != teams[i])                     {                     set_cvar_num("sv_restart", 1)                     cs_set_user_team(i, teams[i])                     cs_set_user_deaths(i, deaths[i])                     set_user_frags(i, frags[i])                     cs_set_user_money(i, money[i], 1)                                         set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)                     show_hudmessage(id, "Your Money/Team/Frags/Death have been restored!")                   }             }         }     }     set_cvar_num("sv_restart", 5) // restart round to make sure changes take effect         console_print(0, "DEBUG 'tester - testPlugin': Phase 2: After for loop - Passed")     console_print(0, "All passed")         return PLUGIN_HANDLED } public plugin_end()     {     if (task_exists())         {         remove_task()     }     return PLUGIN_HANDLED }
Attached Files
File Type: sma Get Plugin or Get Source (tester.sma - 475 views - 4.1 KB)
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
 



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 16:10.


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