AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Correct please modified hat plugin (https://forums.alliedmods.net/showthread.php?t=62192)

dxteam 10-20-2007 14:27

Correct please modified hat plugin
 
1 Attachment(s)
Hi i need help !
My friend make for me one version of my idea hat plugin but every hat add some amount of hp or ap !
He make it but this plugin don`t work no errors on compiling but hats don`t add hp or ap !

M249-M4A1 10-20-2007 14:32

Re: Correct please modified hat plugin
 
Quote:

Originally Posted by dxteam (Post 544375)
Hi i need help !
but every hat add some amount of hp or ap !
but hats don`t add hp or ap !

So what the hell is the problem. Do you want HP/AP per hat, or not?

BY THE WAY. I fixed that damn error. Give it a shot anyway.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>

new g_bwEnt[33]

#define PLUG_NAME "HATS"
#define PLUG_AUTH "SgtBane"
#define PLUG_VERS "0.2"
#define PLUG_TAG "HATS"

#define menusize     220

new HatFile[64]
new 
MenuPagesTotalHats
new CurrentMenu[33]

#define MAX_HATS 64
new HATMDL[MAX_HATS][41]
new 
HATNAME[MAX_HATS][41]

new 
hp_player_bonus[33]
new 
ap_player_bonus[33]

new 
hp_hat_bonus[MAX_HATS]
new 
ap_hat_bonus[MAX_HATS]

public 
plugin_init()
{
    
register_plugin(PLUG_NAMEPLUG_VERSPLUG_AUTH)
    
register_concmd("amx_set_hat_hp""hat_hp"ADMIN_RCON"<mdl #> <hp>")
    
register_concmd("amx_set_hat_ap""hat_ap"ADMIN_RCON"<mdl #> <ap>")
    
register_concmd("amx_givehat""Give_Hat"ADMIN_RCON"<nick> <mdl #>")
    
register_concmd("amx_removehats""Remove_Hat"ADMIN_RCON" - Removes hats from everyone.")
    
register_menucmd(register_menuid("\yHat Menu: [Page"),(1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9),"MenuCommand")
    
register_clcmd("say /hats",        "ShowMenu", -1"Shows Knife menu")
    
register_event("ResetHUD""client_spawn""be")
}

public 
ShowMenu(id)
{
    
CurrentMenu[id] = 1
    ShowHats
(id)
    return 
PLUGIN_HANDLED
}

public 
ShowHats(id)
{
    new 
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
    
    new 
szMenuBody[menusize 1], WpnID
    
new nLen format(szMenuBodymenusize"\yHat Menu: [Page %i/%i]^n",CurrentMenu[id],MenuPages)
    
    
// Get Hat Names And Add Them To The List
    
for (new hatid=0hatid 8hatid++) {
        
WpnID = ((CurrentMenu[id] * 8) + hatid 8)
        if (
WpnID TotalHats) {
            
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w %i. %s",hatid 1,HATNAME[WpnID])
        }
    }
    
    
// Next Page And Previous/Close
    
if (CurrentMenu[id] == MenuPages) {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\d9. Next Page")
        } else {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\w9. Next Page")
    }
    
    if (
CurrentMenu[id] > 1) {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Previous Page")
        } else {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Close")
    }
    
show_menu(idkeysszMenuBody, -1)
    return 
PLUGIN_HANDLED
}
public 
MenuCommand(idkey
{
    switch(
key)
    {
        case 
8:        //9 - [Next Page]
        
{
            if (
CurrentMenu[id] < MenuPagesCurrentMenu[id]++
            
ShowHats(id)
            return 
PLUGIN_HANDLED
        
}
        case 
9:        //0 - [Close]
        
{
            
CurrentMenu[id]--
            if (
CurrentMenu[id] > 0ShowHats(id)
            return 
PLUGIN_HANDLED
        
}
        default:
        {{
                new 
HatID = ((CurrentMenu[id] * 8) + key 8)
                if (
HatID TotalHats) {
                    
Set_Hat(id,HatID,id)
                }
        }}
    }
    return 
PLUGIN_HANDLED
}

public 
plugin_precache()
{
    new 
cfgDir[32]
    
get_configsdir(cfgDir,31)
    
formatex(HatFile,63,"%s/HatList.ini",cfgDir)
    
command_load()
    
    for (new 
1TotalHats; ++i) {
        if (
file_exists (HATMDL[i])) {
            
precache_model(HATMDL[i])
            
server_print("[%s] Precached %s",PLUG_TAG,HATMDL[i])
            } else {
            
server_print("[%s] Failed to precache %s",PLUG_TAG,HATMDL[i])
        }
    }
}

public 
client_connect(id)
{
    if(
g_bwEnt[id] > 0engfunc(EngFunc_RemoveEntity,g_bwEnt[id])
    
g_bwEnt[id] = 0
}

public 
client_disconnect(id)
{
    if(
g_bwEnt[id] > 0engfunc(EngFunc_RemoveEntity,g_bwEnt[id])
    
g_bwEnt[id] = 0
}

public 
Give_Hat(id)
{
    new 
smodelnum[5], name[32]
    
read_argv(1,name,31)
    
read_argv(2,smodelnum,4)
    
    new 
player cmd_target(id,name,2)
    if (!
player) {
        
client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG)
        return 
PLUGIN_HANDLED
    
}
    
    new 
imodelnum = (str_to_num(smodelnum))
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED
    
    Set_Hat
(player,imodelnum,id)
    
    
hp_player_bonus[player]=hp_hat_bonus[imodelnum]
    
ap_player_bonus[player]=ap_hat_bonus[imodelnum]
    
    return 
PLUGIN_CONTINUE
}

public 
hat_hp(id)
{
    new 
smodelnum[5]
    new 
hp[5]
    
read_argv(1,smodelnum,4)
    
read_argv(2,hp,4)
    
    new 
imodelnum = (str_to_num(smodelnum))
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED
    hp_hat_bonus
[imodelnum] = str_to_num(hp)
    
    
    return 
PLUGIN_CONTINUE
}

public 
hat_ap(id)
{
    new 
smodelnum[5]
    new 
ap[5]
    
read_argv(1,smodelnum,4)
    
read_argv(2,ap,4)
    
    new 
imodelnum = (str_to_num(smodelnum))
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED
    ap_hat_bonus
[imodelnum] = str_to_num(ap)
    
    
    return 
PLUGIN_CONTINUE
}


public 
Remove_Hat(id)
{
    for (new 
0get_maxplayers(); ++i) {
        if (
is_user_connected(i) && g_bwEnt[i] > 0) {
            
engfunc(EngFunc_RemoveEntity,g_bwEnt[i])
            
g_bwEnt[i] = 0
        
}
    }
    
client_print(id,print_chat,"[%s] Removed hats from everyone.",PLUG_TAG)
    return 
PLUGIN_CONTINUE
}

public 
Set_Hat(player,imodelnum,targeter)
{
    new 
name[32]
    
get_user_name(playername31)
    if (
imodelnum == 0) {
        if(
g_bwEnt[player] > 0engfunc(EngFunc_RemoveEntity,g_bwEnt[player])
        
g_bwEnt[player] = 0
        client_print
(targeterprint_chat"[%s] Removed hat from %s",PLUG_TAG,name)
        } else if (
file_exists(HATMDL[imodelnum])) {
        if(
g_bwEnt[player] < 1) {
            
g_bwEnt[player] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
            if(
g_bwEnt[player] > 0
            {
                
set_pev(g_bwEnt[player], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_bwEnt[player], pev_aimentplayer)
                
set_pev(g_bwEnt[player], pev_rendermodekRenderNormal)
                
set_pev(g_bwEnt[player], pev_renderamt0.0)
                
engfunc(EngFunc_SetModelg_bwEnt[player], HATMDL[imodelnum])
            }
            } else {
            
engfunc(EngFunc_SetModelg_bwEnt[player], HATMDL[imodelnum])
        }
        
client_print(targeterprint_chat"[%s] Set %s on %s",PLUG_TAG,HATNAME[imodelnum],name)
    }
}

public 
command_load()
{
    if(
file_exists(HatFile)) {
        
HATMDL[0] = ""
        
HATNAME[0] = "None"
        
TotalHats 1
        
new sfLineData[128]
        new 
file fopen(HatFile,"rt")
        while(
file && !feof(file)) {
            
fgets(file,sfLineData,127)
            
            
// Skip Comment and Empty Lines
            
if (containi(sfLineData,";") > -1) continue
            
            
// BREAK IT UP!
            
parse(sfLineDataHATMDL[TotalHats],40,HATNAME[TotalHats],40)
            
            
TotalHats += 1
            
if(TotalHats >= MAX_HATS) {
                
server_print("[%s] Reached hat limit",PLUG_TAG)
                break
            }
        }
        if(
filefclose(file)
    }
    
MenuPages floatround((TotalHats 8.0), floatround_ceil)
    
server_print("[%s] Loaded %i hats, Generated %i pages)",PLUG_TAG,TotalHats,MenuPages)
}

public    
client_spawn id )
{
    
set_user_health(id100+hp_hat_bonus[id])
    
set_user_armor(id100+ap_hat_bonus[id])



dxteam 10-20-2007 17:43

Re: Correct please modified hat plugin
 
Yes i want hp and ap per hat ! )
And i would to save all cvar in new file hatsconfig.cfg or something like that

dxteam 10-20-2007 17:48

Re: Correct please modified hat plugin
 
you script don`t work hats don`t add hp ((

M249-M4A1 10-20-2007 17:49

Re: Correct please modified hat plugin
 
Quote:

Originally Posted by dxteam (Post 544461)
you script don`t work hats don`t add hp ((

I only fixed the error, I didn't do any other changing, or adding hp/ap for that matter. I'll look at it now

dxteam 10-21-2007 14:10

Re: Correct please modified hat plugin
 
Ok when you make this i add to you big respect )

dxteam 10-23-2007 14:37

Re: Correct please modified hat plugin
 
Someone please help with this !!!

dxteam 10-28-2007 15:18

Re: Correct please modified hat plugin
 
uP!!


All times are GMT -4. The time now is 01:23.

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