AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   voting doesn't work (https://forums.alliedmods.net/showthread.php?t=13728)

n0obie4life 05-27-2005 11:07

voting doesn't work
 
Code:
 public cmdknives(id){     new arg[2]     read_argv(1,arg,1)     set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)     if(equal(arg, "1")){         knifeonly = 1         client_cmd(id,"weapon_knife")         console_print(id,"%L",LANG_PLAYER,"KNIVES_TURNED_ON")         client_print(0, print_chat,"%L",LANG_PLAYER, "KNIVES_TURNED_ON")         show_hudmessage(0,"%L",LANG_PLAYER,"KNIVES_ENABLED_HUD")         } else if(equal(arg, "0")){         knifeonly = 0         console_print(id,"%L",LANG_PLAYER,"KNIVES_TURNED_OFF")         client_print(0, print_chat,"%L",LANG_PLAYER, "KNIVES_TURNED_OFF")         show_hudmessage(0,"%L",LANG_PLAYER,"KNIVES_DISABLED_HUD")         }     return PLUGIN_HANDLED  }  public knivesgun(id){     if(knifeonly==0){         //nothing     }     if(knifeonly==1){         new clip, ammo         new usersweapon = get_user_weapon(id,clip,ammo)         if(usersweapon==CSW_KNIFE || usersweapon == CSW_C4 && get_cvar_num("vote_allowc4") == 1 ) {             //nothing             } else {             client_cmd(id,"weapon_knife")         }     }     return PLUGIN_CONTINUE  }  public cmdvoteknives(id){         if (get_cvar_num("vote_knivesvote") == 0 ) {     client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_KNIVES_DISABLED"); }         else if (get_cvar_num ("vote_knivesvote") == 1 ) {             new Float:voting = get_cvar_float("amx_last_voting")     if (voting > get_gametime()){         client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_CASTED")         return PLUGIN_HANDLED     }     if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {         client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_WAIT")         return PLUGIN_HANDLED     }     new menu_msg[256]     new name[32]     format(menu_msg,255,"%L",LANG_PLAYER,"VOTE_KNIVES")     new Float:votetime = get_cvar_float("amx_vote_time") + 10.0     get_user_info(id, "name", name, 31)     set_cvar_float("amx_last_voting",  get_gametime() + votetime )     show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(votetime))     set_task(votetime,"check_the_knife_votes")     client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_STARTED")     choice[0]=choice[1]=0     }     return PLUGIN_HANDLED  }  public count_knivesvotes(id,key){     if (get_cvar_float("amx_vote_answers") ) {         new name[32]         get_user_name(id,name,31)         client_print(0,print_chat,"* %s voted %s", name, key ? "against knives only" : "for knives only" )     }     ++choice[key]     return PLUGIN_HANDLED  }  public check_the_knife_votes(id){     if (choice[0] > choice[1]){         server_cmd("amx_knives 1")         client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_SUCEED_KNIVES",choice[0],choice[1])         } else {         server_cmd("amx_knives 0")         client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_FAILED_KNIVES",choice[0],choice[1])     }     return PLUGIN_HANDLED  }

why doesn't it work? i can't seem to vote...it returns a 0 & 0

WaZZeR++ 05-27-2005 18:58

dont have know, maybe choice[key]++ not ++choice[key].
dont knew if that matters...

faluco 05-27-2005 21:34

I used your code to make a ff voting and it worked, i added also an amx_vote_ratio to improve it, but no more

n0obie4life 05-27-2005 22:23

Quote:

Originally Posted by faluco
I used your code to make a ff voting and it worked, i added also an amx_vote_ratio to improve it, but no more

i tried that and it works, but i don't unerstand why won't it work for my plugin.

okay, maybe i was mentioning this:
Code:
 /******************************Knifes*****************************************/  public cmdknives(id){     new arg[2]     read_argv(1,arg,1)     set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)     if(equal(arg, "1")){         knifeonly = 1         client_cmd(id,"weapon_knife")         console_print(id,"%L",LANG_PLAYER,"KNIVES_TURNED_ON")         client_print(0, print_chat,"%L",LANG_PLAYER, "KNIVES_TURNED_ON")         show_hudmessage(0,"%L",LANG_PLAYER,"KNIVES_ENABLED_HUD")         } else if(equal(arg, "0")){         knifeonly = 0         console_print(id,"%L",LANG_PLAYER,"KNIVES_TURNED_OFF")         client_print(0, print_chat,"%L",LANG_PLAYER, "KNIVES_TURNED_OFF")         show_hudmessage(0,"%L",LANG_PLAYER,"KNIVES_DISABLED_HUD")         }     return PLUGIN_HANDLED  }  public knivesgun(id){     if(knifeonly==0){         //nothing     }     if(knifeonly==1){         new clip, ammo         new usersweapon = get_user_weapon(id,clip,ammo)         if(usersweapon==CSW_KNIFE || usersweapon == CSW_C4 && get_cvar_num("vote_allowc4") == 1 ) {             //nothing             } else {             client_cmd(id,"weapon_knife")         }     }     return PLUGIN_CONTINUE  }  public cmdvoteknives(id){         if (get_cvar_num("vote_knivesvote") == 0 ) {     client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_KNIVES_DISABLED"); }         else if (get_cvar_num ("vote_knivesvote") == 1 ) {             new Float:voting = get_cvar_float("amx_last_voting")     if (voting > get_gametime()){         client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_CASTED")         return PLUGIN_HANDLED     }     if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {         client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_WAIT")         return PLUGIN_HANDLED     }     new menu_msg[256]     new name[32]     format(menu_msg,255,"%L",LANG_PLAYER,"VOTE_KNIVES")     new Float:votetime = get_cvar_float("amx_vote_time") + 10.0     get_user_info(id, "name", name, 31)     set_cvar_float("amx_last_voting",  get_gametime() + votetime )     show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(votetime))     set_task(votetime,"check_the_knife_votes")     client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_STARTED")     choice[0]=choice[1]=0     }     return PLUGIN_HANDLED  }  public count_knivesvotes(id,key){     if (get_cvar_float("amx_vote_answers") ) {         new name[32]         get_user_name(id,name,31)         client_print(0,print_chat,"* %s voted %s", name, key ? "against knives only" : "for knives only" )     }     ++choice[key]     return PLUGIN_HANDLED  }  public check_the_knife_votes(id){     if (choice[0] > choice[1]){         server_cmd("amx_knives 1")         client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_SUCEED_KNIVES",choice[0],choice[1])         } else {         server_cmd("amx_knives 0")         client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_FAILED_KNIVES",choice[0],choice[1])     }     return PLUGIN_HANDLED  }  /******************************AWP*****************************************/  public event_RoundStart_awp() {     if(awponly==0){         //nothing     }     if(awponly==1){         for(new p = 0; p < 32; p++) {             if(is_user_alive(p)) {                 give_item(p, "weapon_awp")                 give_item(p, "ammo_338magnum")                 give_item(p, "ammo_338magnum")                 give_item(p, "ammo_338magnum")             }         }     }     return PLUGIN_HANDLED  }  public cmdawp(id){     new arg[2]     read_argv(1,arg,1)     set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)     if(equal(arg, "1")){         awponly = 1         client_cmd(id,"weapon_knife")         console_print(id,"%L",LANG_PLAYER,"AWP_TURNED_ON")         client_print(0, print_chat,"%L",LANG_PLAYER, "AWP_TURNED_ON")         show_hudmessage(0,"%L",LANG_PLAYER,"AWP_ENABLED_HUD")         } else if(equal(arg, "0")){         awponly = 0         console_print(id,"%L",LANG_PLAYER,"AWP_TURNED_OFF")         client_print(0, print_chat,"%L",LANG_PLAYER, "AWP_TURNED_OFF")         show_hudmessage(0,"%L",LANG_PLAYER,"AWP_DISABLED_HUD")         }     return PLUGIN_HANDLED  }  public awpgun(id){     if(awponly==0){         //nothing     }     if(awponly==1){         new clip, ammo         new usersweapon = get_user_weapon(id,clip,ammo)         if(usersweapon==CSW_KNIFE || usersweapon == CSW_C4 && get_cvar_num("vote_allowc4") == 1 || usersweapon == CSW_AWP ) {             //nothing             } else {             client_cmd(id,"weapon_knife")         }     }     return PLUGIN_CONTINUE  }  public cmdvoteawp(id){         if (get_cvar_num("vote_awpvote") == 0 ) {     client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_AWP_DISABLED"); }         else if (get_cvar_num ("vote_awpvote") == 1 ) {             new Float:voting = get_cvar_float("amx_last_voting")     if (voting > get_gametime()){         client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_CASTED")         return PLUGIN_HANDLED     }     if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {         client_print(id,print_chat,"%L",LANG_PLAYER,"VOTE_WAIT")         return PLUGIN_HANDLED     }     new menu_msg[256]     new name[32]     format(menu_msg,255,"%L",LANG_PLAYER,"VOTE_AWP")     new Float:votetime = get_cvar_float("amx_vote_time") + 10.0     get_user_info(id, "name", name, 31)     set_cvar_float("amx_last_voting",  get_gametime() + votetime )     show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(votetime))     set_task(votetime,"check_the_awp_votes")     client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_STARTED")     choice[0]=choice[1]=0     }     return PLUGIN_HANDLED  }  public count_awpvotes(id,key){     if (get_cvar_float("amx_vote_answers") ) {         new name[32]         get_user_name(id,name,31)         client_print(0,print_chat,"* %s voted %s", name, key ? "against AWP only" : "for AWP only" )     }     ++choice[key]     return PLUGIN_HANDLED  }  public check_the_awp_votes(id){     if (choice[0] > choice[1]){         server_cmd("amx_awp 1")         client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_SUCEED_AWP",choice[0],choice[1])         } else {         server_cmd("amx_awp 0")         client_print(0,print_chat,"%L",LANG_PLAYER,"VOTE_FAILED_AWP",choice[0],choice[1])     }     return PLUGIN_HANDLED  }

faluco 05-28-2005 07:16

this is what i have look:
Code:
public cmdvoteff(id) {     new Float:voting = get_cvar_float("amx_last_voting");         if (voting > get_gametime()) {          client_print(id, print_chat, "*A vote has already been cast.*");         return PLUGIN_HANDLED;     }     if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {         client_print(id, print_chat, "*Please wait a while before you can vote again.*");         return PLUGIN_HANDLED;     }     new menu_msg[256];     new name[32];     format(menu_msg, 255, "\rActivar Fuego Amigo?\R^n^n\y1.\w Si^n\y2.\w No");     new Float:votetime = get_cvar_float("amx_vote_time") + 10.0;     get_user_info(id, "name", name, 31);     set_cvar_float("amx_last_voting", get_gametime() + votetime );     show_menu(0, (1<<0)|(1<<1), menu_msg, floatround(votetime));     set_task(votetime, "check_the_ff_votes");     client_print(0, print_chat, "*Voting has started.*");     choice[0] = choice[1] = 0;         return PLUGIN_HANDLED; } public count_ffvotes(id, key) {     ++choice[key];         return PLUGIN_HANDLED; } public check_the_ff_votes(id) {     new players[32], inum;     get_players(players, inum, "c");     new Float:vote_ratio = get_cvar_float("amx_vote_ratio");     new Float:result = inum ? (float(choice[0] + choice[1]) / float(inum)) : 0.0;         if (result >= vote_ratio) {         if (choice[0] > choice[1]) {             server_cmd("mp_friendlyfire 1");             client_print(0, print_chat, "* Votacion Aprobada para Fuego Amigo (si ^"%d^") (no ^"%d^"). *", choice[0], choice[1]);             client_print(0, print_chat, "* hay un total de %d jugadores. *", inum);         }else{             server_cmd("mp_friendlyfire 0");             client_print(0, print_chat, "* Votacion Fallida para Fuego Amigo (si ^"%d^") (no ^"%d^"). *", choice[0], choice[1]);         }     }else{          client_print(0, print_chat, "* votacion lio, ratio de %f *", result);     }         return PLUGIN_CONTINUE; }


All times are GMT -4. The time now is 16:40.

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