Raised This Month: $ Target: $400
 0% 

Problems with getting data/setting data


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 12-23-2005 , 00:47   Problems with getting data/setting data
Reply With Quote #1

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> 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 temp[128]     read_argv(1,temp,5)     new id=str_to_num(temp) // let's make 'id'     */         new map[64]     get_mapname(map, 63)         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 - testPlugin': Phase 1: Variables - Passed")         for (new a = 1; a <= get_playersnum(); a++)         {         get_user_team(a, teams[a], 2)                 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 %configdir%/info.txt - starts with: name, authid, money, team         format("%s/info.txt", 75, "%s %s %d %s %d %d", directory, names[a], authid[a], money[a], teams[a], frags[a], deaths[a])     }         console_print(0, "DEBUG 'tester - testPlugin': Phase 2: After for loop - Passed")         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(15.0,"changemap()",0) // change map in 15 seconds     set_task(45.0, "revertBack(0)", 0) // call "revertBack" after 45 seconds!         return PLUGIN_CONTINUE } public changemap() {     new map[64]     get_mapname(map, 64)         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++ )         {         get_user_team(i, teams[i], 2)         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)         deaths[i] = get_user_deaths(i)                 read_file("%s/info.txt", i, names[i], 32, names[i+1][i]) // read/save         read_file("%s/info.txt", i, authid[i], 31, authid[i]) // read/save         read_file("%s/info.txt", i, money[i], 31, money[i]) // read/save         read_file("%s/info.txt", i, teams[i], 2, teams[i]) // read/save         read_file("%s/info.txt", i, frags[i], 127, frags[i]) // read/save         read_file("%s/info.txt", i, deaths[i], 127, deaths[i]) // read/save                 while (is_user_connecting(i) == 1)             {             if (is_user_connected(i) == 1)                 {                 //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!")                         }         }             }     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 }

Maybe you can figure out what this plugin will do b/c I do not feel like explaining it as I am hesitant as to releasing it.

It will have no compilation errors/warnings but it gives me run-time errors especially with my arrays being filled by my for loop in my "testPlugin" function.

Here is one of the errors I have received:
Code:
L 12/22/2005 - 21:45:42: [AMXX] Displaying debug trace (plugin "tester.amxx")
L 12/22/2005 - 21:45:42: [AMXX] Run time error 4: index out of bounds (array "names[32]") (indexed "[2]")
L 12/22/2005 - 21:45:42: [AMXX]    [0] tester.sma::testPlugin (line 28)
__________________
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