Raised This Month: $ Target: $400
 0% 

Solved Name of client in PrintHintTextToAll


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Walgrim
AlliedModders Donor
Join Date: Dec 2015
Location: France
Old 11-26-2017 , 13:40   Re: Name of client in PrintHintTextToAll
Reply With Quote #13

Well I post mine too, even if people are faster than me :^)
PHP Code:
#include <sourcemod>
#define REQUESTHEAL "#heal"

Handle Delay[MAXPLAYERS+1] = null;
int TimerCount[MAXPLAYERS+1];

public 
Plugin:myinfo =
{
    
name "HealRequestMenu",
    
author "Walgrim",
    
description "Displays a menu to request heal",
    
version "1.0",
    
url "http://steamcommunity.com/id/walgrim/"
};

public 
void OnPluginStart() {
  
RegConsoleCmd("sm_menu"Command_DisplayMenu"A command that displays the menu");
}

public 
int MenuHandler(Menu menuMenuAction actionint param1int param2) {
  switch (
action) {
    case 
MenuAction_Select:
    {
      
char info[32];
      
menu.GetItem(param2infosizeof(info));
      if (
StrEqual(infoREQUESTHEAL)) {
        if (
TimerCount[param1] < 1) {
          
CreateTimer(0.1PrintHintGetClientUserId(param1));
          
Delay[param1] = CreateTimer(1.0Timer_CountdownGetClientUserId(param1), TIMER_REPEAT);
        }
      }
    }
    case 
MenuAction_DisplayItem:
    {
      
char info[32], display[64];
      
menu.GetItem(param2infosizeof(info));
      if (
TimerCount[param1] < 30 && TimerCount[param1] > 0) {
        if (
StrEqual(infoREQUESTHEAL)) {
          
Format(displaysizeof(display), "Request Heal (Available in %i secs)"30 TimerCount[param1]);
          return 
RedrawMenuItem(display);
        }
      }
    }
    case 
MenuAction_DrawItem:
    {
      
char info[32];
      
menu.GetItem(param2infosizeof(info));
      if (
TimerCount[param1] < 30 && TimerCount[param1] > 0) {
        if (
StrEqual(infoREQUESTHEAL)) {
          return 
ITEMDRAW_DISABLED;
        }
      }
    }
    case 
MenuAction_End:
    {
      
delete menu;
    }
  }
  return 
0;
}

public 
Action Command_DisplayMenu(int clientint args) {
  
Menu menu = new Menu(MenuHandlerMenuAction_Select|MenuAction_DisplayItem|MenuAction_DrawItem|MenuAction_End);
  
menu.SetTitle("Your menu title");
  
menu.AddItem(REQUESTHEAL"Request Heal");
  
menu.ExitButton true;
  
menu.Display(client35);
  return 
Plugin_Handled;
}

public 
Action PrintHint(Handle Timerint clientid)
{
    
int client GetClientOfUserId(clientid);
    if (
client == 0) {
      return 
Plugin_Continue;
    }
    
PrintHintTextToAll("%N want heal!"client);
    return 
Plugin_Continue;
}

public 
Action Timer_Countdown(Handle Timerint clientid) {
    
int client GetClientOfUserId(clientid);
    if (
client == 0) {
        return 
Plugin_Continue;
    }
    
TimerCount[client]++;
    if (
TimerCount[client] > 30) {
    
ClearTimer(Delay[client]);
    
TimerCount[client] = 0;
    }
    return 
Plugin_Continue;
}

stock ClearTimer(&Handle:hTimer) {
    if (
hTimer != null) {
        
KillTimer(hTimer);
        
hTimer null;
    }

(I would be interested if someone tells me a better way to do a countdown like I did (with secs displaying))
Attached Files
File Type: sp Get Plugin or Get Source (HealRequestMenu.sp - 227 views - 2.7 KB)
__________________

Last edited by Walgrim; 11-29-2017 at 08:58.
Walgrim 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 21:09.


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