Raised This Month: $ Target: $400
 0% 

Help vote


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-11-2016 , 09:38   Re: Help vote
Reply With Quote #4

Try :


PHP Code:
//Add these 2 defines at the top of your plugin
#define TIME 10.0  //This is time after results will be checked, you can change it's value
#define TASK_CHECK 6459 //This is task id used to check if another task is not in process

public vote()
{
    if(
task_exists(TASK_CHECK)){
        return 
PLUGIN_HANDLED
        
//Blocking vote if another one is started or is in process

    
new ad[32],sznum[6]
    new 
menu menu_create("\rVote For CT","vote_handler")
    for(new 
1;i<=get_maxplayers();i++)
    if(
is_user_connected(i) && get_user_team(i) == 2)
    
    
    
    {
        
num_to_str(i,sznum,5)
        
get_user_name(i,ad,31)
        
menu_additem(menu,ad,sznum)
        
        
        
    }
    
arrayset(g_votes33)//Cleaning the array before vote
    
menu_display(id,menu0)
    
set_task(TIMEcheck_resultTASK_CHECK//Setting a task to check our results
    
return PLUGIN_HANDLED
}

public 
vote_handler(id,menu,item)
{
    if(
item == MENU_EXIT)
    
    
    
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
        
        
        
    
}

        new 
ad[32],callback,access,data[6]
        
menu_item_getinfo(menu,item,access,data,5,ad,31,callback)
        new 
tid str_to_num(data)
        
g_votes[tid]++

}

public 
check_results(){

  new 
leader;
  
  for(new 
i33i++){
  
  for(new 
j33j++){
  
  if(
g_votes[i] < g_votes[j])
  break;
  
  if(
j==32)
  
leader=g_votes[i]
  }
  }
  if(
is_user_connected(leader))
  {
  
name[32]
  
get_user_name(leadername31)
  
client_print(0print_chat"[VOTE RESULT] The most voted player is ^"%s^""name)
  }else{
  
client_print(0print_chat"[VOTE RESULT] Vote has failed. Player is not connected")
  }


Last edited by siriusmd99; 05-11-2016 at 09:44.
siriusmd99 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 18:35.


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