Raised This Month: $51 Target: $400
 12% 

Weird menu error killing people/changing teams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slurpycof
Senior Member
Join Date: Nov 2004
Old 03-08-2005 , 15:21   Weird menu error killing people/changing teams
Reply With Quote #1

This is my first plugin that I wrote a couple of weeks ago and I am getting a few reports about weird things happening. It seems like sometimes when people vote while alive they die or if they are dead, it brings up switch team menu. I am not by any means a coder, and I would like someone to take a look at this and see if it my plugin or a conflict somewhere else. I have never seen it happen myself.

Code:
#include <amxmodx>  #include <dbi>  new Sql:dbc  new Result:result  new state[3]  new nowstate[3]  new plnum  new bshow = true  new Float:total  public plugin_init() {     register_plugin("SQL Map Rank","0.1","Slurpy [COF]")     register_menucmd(register_menuid("What do you think about "),(1<<0)|(1<<1)|(1<<2),"vote_count")     set_task(10.0,"read_rate",777,"",0,"b")     set_task(10.0,"sql_init")     register_cvar("amx_mapvotemode", "3")  }  public sql_init() {     new host[64], username[32], password[32], dbname[32], error[32]     get_cvar_string("amx_sql_host",host,64)     get_cvar_string("amx_sql_user",username,32)     get_cvar_string("amx_sql_pass",password,32)     get_cvar_string("amx_sql_db",dbname,32)     dbc = dbi_connect(host,username,password,dbname,error,32)     if (dbc == SQL_FAILED)     log_amx("[AMXX] SQL Connection Failed")     else     {         dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `maprank` ( `map_name` VARCHAR(32) NOT NULL,`good` INT NOT NULL, `okay` INT NOT NULL, `bad` INT NOT NULL, `total` INT NOT NULL, PRIMARY KEY(`map_name`))")     }     dbi_free_result(result)     return PLUGIN_CONTINUE }  public sql_insert() {     if (dbc == SQL_FAILED) return PLUGIN_CONTINUE     new mapname[33]     get_mapname(mapname,32)     new totalint     totalint = floatround(total)     //Insert map information into the tables     result = dbi_query(dbc,"SELECT * FROM maprank where map_name ='%s'",mapname)     if (dbi_num_rows(result) < 1) {         result = dbi_query(dbc,"INSERT INTO maprank (map_name, good, okay, bad, total) values ('%s',%i,%i,%i,%i)",mapname,state[0],state[1],state[2],totalint)     }else{         result = dbi_query(dbc,"UPDATE maprank SET good=good+%i, okay=okay+%i, bad=bad+%i, total=total+%i WHERE map_name='%s'",state[0],state[1],state[2],totalint,mapname)     }     dbi_free_result(result)     return PLUGIN_CONTINUE }  public ask_menu() {     new menu[256]     new mapname[33]     get_mapname(mapname,32)     plnum = 0     nowstate[0] = 0     nowstate[1] = 0     nowstate[2] = 0     //Display the voting menu     format(menu,255,"\yWhat do you think about %s?\w^n^n1.  Very Good ! !^n2.  Medium .^n3.  So Bad . . .",mapname)     show_menu(0,(1<<0)|(1<<1)|(1<<2),menu,10)     client_cmd(0,"spk Gman/Gman_Choose2")     set_task(10.0,"end_conduct")     client_print(0,print_chat,"* Conducting a survey of players...")  }  public vote_count(id,key) {     new name[32]     get_user_name(id,name,31)     if(key == 0) {         if (get_cvar_num("amx_mapvotemode")== 1){ //no print             state[0]++             nowstate[0]++             return PLUGIN_CONTINUE             } else if (get_cvar_num("amx_mapvotemode")== 2) {  //admin print             new players[32], num             get_players(players, num)             new i             for (i=0; i<num; i++)             {                 if (!(get_user_flags(id)&ADMIN_IMMUNITY))     return PLUGIN_CONTINUE                 client_print(i,print_chat,"* %s selected Very Good!!",name)             }             state[0]++             nowstate[0]++             return PLUGIN_CONTINUE             } else {             client_print(0,print_chat,"* %s selected Very Good!!",name)             state[0]++             nowstate[0]++             return PLUGIN_CONTINUE         }     }     if(key == 1) {         if (get_cvar_num("amx_mapvotemode")== 1){ //no print             state[1]++             nowstate[1]++             return PLUGIN_CONTINUE             } else if (get_cvar_num("amx_mapvotemode")== 2) {  //admin print             new players[32], num             get_players(players, num)             new i             for (i=0; i<num; i++)             {                 if (!(get_user_flags(id)&ADMIN_IMMUNITY))     return PLUGIN_CONTINUE                 client_print(i,print_chat,"* %s selected Medium!",name)             }             state[1]++             nowstate[1]++             return PLUGIN_CONTINUE             } else {             client_print(0,print_chat,"* %s selected Medium!",name)             state[1]++             nowstate[1]++             return PLUGIN_CONTINUE         }     }     if(key == 2) {         if (get_cvar_num("amx_mapvotemode")== 1){ //no print             state[2]++             nowstate[2]++             return PLUGIN_CONTINUE             } else if (get_cvar_num("amx_mapvotemode")== 2) {  //admin print             new players[32], num             get_players(players, num)             new i             for (i=0; i<num; i++)             {                 if (!(get_user_flags(id)&ADMIN_IMMUNITY))     return PLUGIN_CONTINUE                 client_print(i,print_chat,"* %s selected So Bad..!!",name)             }             state[2]++             nowstate[2]++             return PLUGIN_CONTINUE             } else {             client_print(0,print_chat,"* %s selected So Bad..!!",name)             state[2]++             nowstate[2]++             return PLUGIN_CONTINUE         }     }     plnum++     return PLUGIN_CONTINUE  }  public end_conduct(id) {     new Float:ans[3]     new Float:tans[3]     new name[32]     get_user_name(id,name,31)     if(nowstate[0] == 0) {         nowstate[0] = 0         }else {         ans[0] = float(nowstate[0]) / float(plnum)     }     if(nowstate[2] == 0) {         nowstate[2] = 0         }else {         ans[2] = float(nowstate[2]) / float(plnum)     }     ans[1] = 1.00 - (ans[0] + ans[2])     if (get_cvar_num("amx_mapvotemode")== 1){ //no print         } else if (get_cvar_num("amx_mapvotemode")== 2) {  //admin print         new players[32], num         get_players(players, num)         new i         for (i=0; i<num; i++)         {             if (!(get_user_flags(id)&ADMIN_IMMUNITY))     return PLUGIN_CONTINUE             client_print(i,print_chat,"* Now Rate : Very Good!!!(%.2f) Medium.(%.2f) So Bad...(%.2f)",ans[0],ans[1],ans[2])         }         } else {         client_print(0,print_chat,"* Now Rate : Very Good!!!(%.2f) Medium.(%.2f) So Bad...(%.2f)",ans[0],ans[1],ans[2])     }     total = float(state[0] + state[1] + state[2])     if(state[0] == 0) {         tans[0] = float(0)         }else {         tans[0] = float(state[0]) / total     }     if(state[2] == 0) {         tans[2] = float(0)         }else {         tans[2] = float(state[2]) / total     }     tans[1] = 1.00 - (tans[0] + tans[2])     if (get_cvar_num("amx_mapvotemode")== 1){ //no print         } else if (get_cvar_num("amx_mapvotemode")== 2) {  //admin print         new players[32], num         get_players(players, num)         new i         for (i=0; i<num; i++)         {             if (!(get_user_flags(id)&ADMIN_IMMUNITY))     return PLUGIN_CONTINUE             client_print(i,print_chat,"* Total Rate : Very Good!!!(%.2f) Medium.(%.2f) So Bad...(%.2f)",tans[0],tans[1],tans[2])         }         } else {         client_print(0,print_chat,"* Total Rate : Very Good!!!(%.2f) Medium.(%.2f) So Bad...(%.2f)",tans[0],tans[1],tans[2])     }     sql_insert()     return PLUGIN_CONTINUE  }  public read_rate() {     new timeleft = get_timeleft()     if(bshow&&(timeleft>0)&&(timeleft<300)) {         bshow = false         ask_menu()     }  }
slurpycof is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-08-2005 , 18:30  
Reply With Quote #2

I don't see anything that would cause what you are describing.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
slurpycof
Senior Member
Join Date: Nov 2004
Old 03-08-2005 , 20:31  
Reply With Quote #3

Thank you for taking the time to look. I have been beating my head and reading alot of plugins to see if I did something wrong. At least I am learning in the process.
slurpycof is offline
Reply



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 13:56.


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