Raised This Month: $ Target: $400
 0% 

HP Modification Issue: Need Help! KNIFE PLUGIN


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 12-11-2023 , 20:00   Re: HP Modification Issue: Need Help! KNIFE PLUGIN
Reply With Quote #1

1. you can define the needed access directly in register_clcmd, no need to check if user is admin in function
Quote:
Originally Posted by amxmodx.inc
/* Registers function which will be called from client console.
* Set FlagManager to 1 to make FlagManager always include this command
* Set FlagManager to 0 to make FlagManager never include this command
* Returns the command ID.
*/
native register_clcmd(const client_cmd[],const function[],flags=-1, const info[]="", FlagManager=-1);
2. you can just register all say commands and filter them inside a single function. see this code as an example:
PHP Code:
public plugin_init()
    
register_clcmd("say""fwClCmdSay")

public 
fwClCmdSay(const iID)
{
    new 
szTemp[1]; // first char will be " second char /
    
read_args(szTempcharsmax(szTemp))
    
    
trim(szTemp)
    
remove_quotes(szTemp)
    
replace(szTempcharsmax(szTemp), "/""")
    
replace(szTempcharsmax(szTemp), ".""")
    
replace(szTempcharsmax(szTemp), "!""")
    
    if (
equali(szTemp"restart") || equali(szTemp"rr"))
    {
        
fwConCmdRestart(iID)
        
        return 
PLUGIN_HANDLED_MAIN;
    }
    else if (
equali(szTemp"warm") || equali(szTemp"wrm"))
    {
        
fwConCmdWarm(iID)
        
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    return 
PLUGIN_CONTINUE;

3. instead of looping through all player ids you can get them all filtered with a single native which is faster
Quote:
Originally Posted by amxmodx.inc
/* Sets indexes of players.
* Flags:
* "a" - don't collect dead players.
* "b" - don't collect alive players.
* "c" - skip bots.
* "d" - skip real players.
* "e" - match with team.
* "f" - match with part of name.
* "g" - ignore case sensitivity.
* "h" - skip HLTV.
* Example: Get all alive CTs: get_players(players,num,"ae","CT") */
native get_players(players[32], &num ,const flags[]="", const team[]="");
Usage example:
PHP Code:
    new iCVarHUD get_pcvar_num(g_iIDPCVarHUD), iiIDsPlayers[32], iCountPlayers;
    
//client_print(0, print_chat, "[fwTaskShowHUD] C4: (%d)%s.", iIDsPlayers[i], szTemp)
    
    
if (iCVarHUD 1)
    {
        
// red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65,
        // effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0,
        // Float:fadeintime = 0.1, Float:fadeouttime = 1.5, bool:reliable = true
        #if defined _dhudmessage_included
        
set_dhudmessage
        
(
            
25500, -1.00.900.0,
            
0.1 BOMBMSG_INTERVAL10.00.0false
        
)
        
#else
        
set_dhudmessage
        
(
            
25500, -1.00.900.0,
            
0.1 BOMBMSG_INTERVAL10.00.0
        
)
        
#endif
    
}
    else
        
set_hudmessage(25500, -1.00.900.00.1 BOMBMSG_INTERVAL10.00.0)

    
get_players(iIDsPlayersiCountPlayers"ec""SPECTATOR")
    
    for (
0iCountPlayersi++)
    {
        if (
iCVarHUD 1)
            
show_dhudmessage(iIDsPlayers[i], "C4: %s%s%.1f m%s"g_szName[0] ? g_szName ""g_szName[0] ? "(" ""fm_entity_range(g_iIDEntBombiIDsPlayers[i]) / 25.4g_szName[0] ? ")" "")
        else
            
show_hudmessage(iIDsPlayers[i], "C4: %s%s%.1f m%s"g_szName[0] ? g_szName ""g_szName[0] ? "(" ""fm_entity_range(g_iIDEntBombiIDsPlayers[i]) / 25.4g_szName[0] ? ")" "")
    } 
4. instead of having 2 variables you can just have 1 and store the hp which should be set on the players
5. you should try using dhud since your message is displayed only once and not spammed. unlike default hud, it has auto resize and looks better. if you're using amxx <= 182 download the necessarry include file from here otherwise this step is not needed: https://forums.alliedmods.net/attach...4&d=1583426083
Very good job overall for your first plugin. Congrats.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
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 00:32.


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