Raised This Month: $32 Target: $400
 8% 

[REQ] Rewrite this plugin to HL1 please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 07-24-2011 , 08:36   [REQ] Rewrite this plugin to HL1 please
Reply With Quote #1

http://forums.alliedmods.net/showthread.php?t=57899

I need this plugin in HL1 server..

This is a weapon list:

HLW_NONE
HLW_CROWBAR
HLW_GLOCK
HLW_PYTHON
HLW_MP5
HLW_CHAINGUN
HLW_CROSSBOW
HLW_SHOTGUN
HLW_RPG
HLW_GAUSS
HLW_EGON
HLW_HORNETGUN
HLW_HANDGRENADE
HLW_TRIPMINE
HLW_SATCHEL
HLW_SNARK

Help me pls.. I tried.. but my work does not give results..
Attached Files
File Type: sma Get Plugin or Get Source (map_weapons_manager.sma - 525 views - 9.7 KB)
__________________
sorry my bad english...
alonelive is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 07-24-2011 , 11:08   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #2

Hust need replace weapon list, but a don't know hos do this.

HLW_crowbar or weapon_crowbar or crowbar ? ...
I can not understand how the classification is made in an array of weapons
PHP Code:
new g_WeaponNames[19][] = {
    
"MP5",
    
"TMP",
    
"P90",
    
"MAC10",
    
"AK47",
    
"SG552",
    
"M4A1",
    
"AUG",
    
"Scout",
    
"G3SG1",
    
"AWP",
    
"M3",
    
"XM1014",
    
"M249",
    
"Flashbang",
    
"HE Grenade",
    
"Kevlar",
    
"Kevlar + Helmet",
    
"Smoke Grenade"

__________________
sorry my bad english...
alonelive is offline
cevaps
Member
Join Date: Apr 2008
Location: Turkiye
Old 02-09-2012 , 17:28   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #3

i'm also interested with this
cevaps is offline
Send a message via ICQ to cevaps Send a message via MSN to cevaps
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 02-10-2012 , 03:09   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #4

Quote:
Originally Posted by alonelive View Post
Hust need replace weapon list, but a don't know hos do this.

HLW_crowbar or weapon_crowbar or crowbar ? ...
I can not understand how the classification is made in an array of weapons
PHP Code:
new g_WeaponNames[19][] = {
    
"MP5",
    
"TMP",
    
"P90",
    
"MAC10",
    
"AK47",
    
"SG552",
    
"M4A1",
    
"AUG",
    
"Scout",
    
"G3SG1",
    
"AWP",
    
"M3",
    
"XM1014",
    
"M249",
    
"Flashbang",
    
"HE Grenade",
    
"Kevlar",
    
"Kevlar + Helmet",
    
"Smoke Grenade"

I think the crowbar is the same as a knife..
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 02-10-2012 , 06:01   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #5

actually, those are hl1 weapons names

PHP Code:
"weapon_9mmAR"
"weapon_9mmhandgun",
 
"weapon_crossbow"
"weapon_egon"
"weapon_gauss",
"weapon_glock"
"weapon_handgrenade"
"weapon_hornetgun",
 
"weapon_mp5"
"weapon_python",
"weapon_rpg"
"weapon_satchel"
"weapon_shotgun",
 
"weapon_snark"
"weapon_tripmine" 
"weapon_crowbar" 
if it helps
__________________

Last edited by tuty; 02-10-2012 at 06:02.
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
cevaps
Member
Join Date: Apr 2008
Location: Turkiye
Old 02-10-2012 , 15:57   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #6

Quote:
Originally Posted by tuty View Post
actually, those are hl1 weapons names

PHP Code:
"weapon_9mmAR"
"weapon_9mmhandgun",
 
"weapon_crossbow"
"weapon_egon"
"weapon_gauss",
"weapon_glock"
"weapon_handgrenade"
"weapon_hornetgun",
 
"weapon_mp5"
"weapon_python",
"weapon_rpg"
"weapon_satchel"
"weapon_shotgun",
 
"weapon_snark"
"weapon_tripmine" 
"weapon_crowbar" 
if it helps
changed weapons as you said, but i got an error while compiling it.



can someone help me to compile it? i really need to make weapons stay even someone takes it in hl:dm.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define MAX_ENTITIES 100
#define MAX_CREATED_ENTITIES MAX_ENTITIES / 2


// ----------FAKEMETA_UTIL----------------
#define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
#define fm_get_entity_visibility(%1) (!(pev(%1, pev_effects) & EF_NODRAW))
#define fm_DispatchSpawn(%1) dllfunc(DLLFunc_Spawn, %1)
#define fm_find_ent_in_sphere(%1,%2,%3) engfunc(EngFunc_FindEntityInSphere, %1, %2, %3)

stock fm_entity_set_origin(index, const Float:origin[3]) {
    new 
Float:mins[3], Float:maxs[3]
    
pev(indexpev_minsmins)
    
pev(indexpev_maxsmaxs)
    
engfunc(EngFunc_SetSizeindexminsmaxs)

    return 
engfunc(EngFunc_SetOriginindexorigin)
}

stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
    if (
classname[0])
        
set_kvd(0KV_ClassNameclassname)
    else {
        new class[
32]
        
pev(entitypev_classname, class, sizeof class - 1)
        
set_kvd(0KV_ClassName, class)
    }

    
set_kvd(0KV_KeyNamekey)
    
set_kvd(0KV_Valuevalue)
    
set_kvd(0KV_fHandled0)

    return 
dllfunc(DLLFunc_KeyValueentity0)
}
// --------------------------------------
new cvar_on
new cvar_time

new g_IndexList[MAX_ENTITIES]
new 
g_IndexListSize 0
new g_CountList[MAX_ENTITIES]
new 
g_ItemList[MAX_ENTITIES]
new 
Float:g_OriginList[MAX_ENTITIES][3]
new 
g_LastEnt

new g_NewIndexList[MAX_ENTITIES]

new 
Float:g_TimeList[19]

new 
g_LineList[MAX_ENTITIES]
new 
g_LineSize 0

new g_WeaponNames[19][] = {
    
"weapon_9mmAR"
    
"weapon_9mmhandgun",
    
"weapon_crossbow"
    
"weapon_egon"
    
"weapon_gauss",
    
"weapon_glock"
    
"weapon_handgrenade"
    
"weapon_hornetgun",
    
"weapon_mp5"
    
"weapon_python",
    
"weapon_rpg"
    
"weapon_satchel"
    
"weapon_shotgun",
    
"weapon_snark"
    
"weapon_tripmine" 
    "weapon_crowbar"
}

new 
g_ConfigsDir[64]
new 
g_MapName[32]

public 
plugin_precache() {
    
register_forward(FM_KeyValue,"log_weapons")
}

public 
plugin_init() {
    
register_plugin("Weapon Respawner","1.0","danielkza")
    
    
cvar_on register_cvar("weapon_respawn","1")
    
cvar_time register_cvar("weapon_respawn_time","10.0")
    
    
copy(g_NewIndexList,sizeof g_IndexList,g_IndexList)
    
register_forward(FM_Touch,"touch")
    
register_clcmd("weapon_create","createspawn_cmd",ADMIN_RCON,"<weapon_name count> - Creates a permanent weapon spawn of given weapon name on your current position")
    
register_clcmd("weapon_delete","removespawn_cmd",ADMIN_RCON,"Removes closest weapon spawn.Be careful:original map weapons can only be restored manually"
    for(new 
i=0;i<g_IndexListSize;i++) {
        
pev(g_IndexList[i],pev_origin,g_OriginList[i])
    }
}

public 
plugin_cfg() {
    
arrayset(g_LineList,-1,sizeof g_LineList)
    new 
filename[90]
    
get_configsdir(g_ConfigsDir,63)
    
get_mapname(g_MapName,31)
    
    
format(filename,99,"%s/weapons",g_ConfigsDir)
    if (!
dir_exists(filename))
        
mkdir(filename)
    
    
format(filename,89,"%s/weapons/RespawnTimes.cfg",g_ConfigsDir)
    new 
linestr[64],weapstr[20],i,file
    
if(!file_exists(filename)) {
        
file fopen(filename,"w+")
        for(
i=0;sizeof g_WeaponNames;i++) {
            
fprintf(file,"^"%s^" ^"default^"^n",g_WeaponNames[i])
        }
        
fclose(file)
    }
    else {
        new 
timestr[20],weapnum
        file 
fopen(filename,"r")
        if (!
file)
            
server_print("[AMXX] Error: can't read file %s",filename)
        while((
fgets(file,linestr,63))) {
            
replace(linestr,sizeof linestr,"^n","")
            
parse(linestr,weapstr,19,timestr,19)
            if(!
equali(timestr,"default")) {
                
weapnum find_string_in_array(weapstr,g_WeaponNames,sizeof g_WeaponNames)
                if(
weapnum > -1)
                    
g_TimeList[weapnum] = str_to_float(timestr)
            }
        }
        
fclose(file)
    }

    
format(filename,89,"%s/weapons/%s.cfg",g_ConfigsDir,g_MapName)
    if(
file_exists(filename)) {
        new 
countstr[4],x[16],y[16],z[16],Float:origin[3],line
        file 
fopen(filename,"r")
        
        while((
fgets(file,linestr,63)) && g_IndexListSize MAX_ENTITIES) {
            
replace(linestr,sizeof linestr,"^n","")
            
parse(linestr,weapstr,19,countstr,3,x,15,y,15,z,15)
            
            new 
weapnum find_string_in_array(weapstr,g_WeaponNames,sizeof g_WeaponNames)
            if (
weapnum == -1)
                
server_print("[AMXX] Error parsing custom spawn: Weapon %s not found",weapstr)
            else {
                
origin[0] = str_to_float(x)
                
origin[1] = str_to_float(y)
                
origin[2] = str_to_float(z)
                
                
createspawn(weapnum,str_to_num(countstr),origin,line++)
                
            }
        }
        
fclose(file)
    }
}

public 
log_weapons(entKVD_Handle) {
    
// Skip Players and check if entity is valid
    
if (g_IndexListSize >= MAX_ENTITIES || ent <= get_maxplayers() || !pev_valid(ent))
        return 
FMRES_IGNORED
        
    
// Start reading of KeyValues
    
static class[32]
    
    
get_kvd(KVD_HandleKV_ClassName, class,31)
    
    
// Too Obvious
    
if (!equali(class, "armoury_entity"))
        return 
FMRES_IGNORED
    
    
static key[32], value[32
    new 
numvalue
    
    
// Check if entity's index hasn't been logged yet
    // and if negative, do it
    
if (ent != g_LastEnt) {
        if(
g_LastEnt 0)
            
g_IndexList[++g_IndexListSize] = ent
        
else
            
g_IndexList[g_IndexListSize] = ent
        g_LastEnt 
ent
    
}
    
    
get_kvd(KVD_HandleKV_KeyNamekey31)
    
get_kvd(KVD_HandleKV_Valuevalue31)
    
numvalue str_to_num(value)
    
    
// Log the keys and values of the weapons to an array
    
if (equali(key,"count",5)) {
        
g_CountList[g_IndexListSize] = numvalue
    
}
    
    if(
equali(key,"item",4)) {
        
g_ItemList[g_IndexListSize] = numvalue
    
}
    

    
    return 
FMRES_IGNORED
}

public 
createspawn_cmd(id,level,cid) {
    if(!
cmd_access(id,level,cid,3))
        return 
PLUGIN_HANDLED
    
    
if(g_IndexListSize >= MAX_ENTITIES) {
        
client_print(id,print_console,"Error: Max spawns reached.Try deleting others to create more.")
        return 
PLUGIN_HANDLED
    
}
    new 
weaponarg[20],weaponcount[8],count,weapnum
    read_argv
(1,weaponarg,19)
    
read_argv(2,weaponcount,7)
    
    
count=str_to_num(weaponcount)
    
    
weapnum find_string_in_array(weaponarg,g_WeaponNames,sizeof g_WeaponNames)
    if (
weapnum == -1) {
        
client_print(id,print_console,"[AMXX] Error: Weapon not found")
        return 
PLUGIN_HANDLED
    
}
    
    if (!
is_user_connected(id))
        return 
PLUGIN_HANDLED
        
    
new Float:origin[3]    
    
pev(id,pev_origin,origin)
    
    
createspawn(weapnum,count,origin,g_LineSize)
    
    new 
filename[100],linestr[100]

    
format(filename,99,"%s/weapons/%s.cfg",g_ConfigsDir,g_MapName)
    
format(linestr,100,"^"%s^" %d %f %f %f",g_WeaponNames[weapnum],count,origin[0],origin[1],origin[2])
    
    
write_file(filename,linestr,-1)
    
client_print(id,print_console,"Weapon %s created sucessfully",g_WeaponNames[weapnum])
    
    return 
PLUGIN_HANDLED
}

public 
createspawn(weapnum,count,Float:origin[3],line) {
    new 
ent create_armoury_entity(weapnum,count,origin)
    if (!
ent) return 0
    
else {
        
g_LineList[g_IndexListSize] = line
        g_LineSize
++
        
        
g_NewIndexList[g_IndexListSize] = ent
        g_ItemList
[g_IndexListSize] = weapnum
        g_CountList
[g_IndexListSize] = count
        g_OriginList
[g_IndexListSize++] = origin
    
}
    return 
ent
}

public 
removespawn_cmd(id,level,cid) {
    if(!
cmd_access(id,level,cid,0))
        return 
PLUGIN_HANDLED

    
if (!is_user_connected(id))
        return 
PLUGIN_HANDLED
        
    
new Float:origin[3]    
    
pev(id,pev_origin,origin)
    
    new 
ent,arraypos,filename[100]
    
format(filename,99,"%s/weapons/%s.cfg",g_ConfigsDir,g_MapName)
    
    while((
ent=fm_find_ent_in_sphere(ent,origin,50.0))) {
        if((
arraypos=find_int_in_array(ent,g_NewIndexList,g_IndexListSize)) != -1) {
            if (
g_LineList[arraypos] > -1) {
                
write_file(filename,"",g_LineList[arraypos])
                
fm_remove_entity(g_NewIndexList[arraypos])
            }
            else {
                
client_print(id,print_console,"[AMXX] Error: You can only delete weapons created by the plugin")
                return 
PLUGIN_HANDLED
            
}
                    
            for(new 
i=arraypos+1;g_IndexListSize;i++) {
                
g_NewIndexList[i-1] = g_NewIndexList[i]
            }
            
g_NewIndexList[g_IndexListSize--] = 0
            client_print
(id,print_console,"[AMXX] Weapon deleted sucessfully")
            return 
PLUGIN_HANDLED
        
}
    }
    
    
client_print(id,print_console,"[AMXX] No plugin-created weapon spawns near enough")
    
    return 
PLUGIN_HANDLED
}

public 
touch(touched,toucher) {
    if (!
get_pcvar_num(cvar_on) || !pev_valid(touched) || !pev_valid(toucher))
        return 
FMRES_IGNORED
        
    
new class[32]
    
pev(touched,pev_classname,class,31)
    if (!
equali(class,"armoury_entity") && !equali(class,"item_kevlar") && !equali(class,"item_assaultsuit")) {
        return 
FMRES_IGNORED
    
}
    
    new 
arraypos find_int_in_array(touched,g_NewIndexList,g_IndexListSize)
    if (
arraypos == -1) return FMRES_IGNORED
    
    
new Float:time
    
if(!(time=g_TimeList[g_ItemList[arraypos]]))    
        
time get_pcvar_float(cvar_time)    

    
set_task(time,"respawn_weapon",arraypos)
    return 
FMRES_IGNORED
}

public 
create_armoury_entity(item,count,Float:origin[3]) {
    new 
ent,item_string[3],count_string[4]
    
ent fm_create_entity("armoury_entity")
    if (!
pev_valid(ent)) 
        return 
0
    num_to_str
(item,item_string,2)
    
num_to_str(count,count_string,3)
    
fm_set_kvd(ent,"item",item_string,"armoury_entity")
    
fm_set_kvd(ent,"count",count_string,"armoury_entity")
    
fm_DispatchSpawn(ent)
    
fm_entity_set_origin(ent,origin)
    return 
ent
}

public 
find_int_in_array(num,array[],len) {
    for(new 
i=0;len;i++) {
        if (array[
i] == num) {
            return 
i
        
}
    }
    return -
1
}

public 
find_string_in_array(string[],array[][],len) {
    for(new 
i=0;len;i++) {
        if (
equali(array[i],string)) {
            return 
i
        
}
    }
    return -
1
}

public 
respawn_weapon(arraypos) {
    if (
g_NewIndexList[arraypos] && fm_get_entity_visibility(g_NewIndexList[arraypos]))
        return
    else if (
pev_valid(g_NewIndexList[arraypos])) 
        
fm_remove_entity(g_NewIndexList[arraypos])
    new 
ent create_armoury_entity(g_ItemList[arraypos],g_CountList[arraypos],g_OriginList[arraypos])
    if (
pev_valid(ent)) {
        
g_NewIndexList[arraypos] = ent
    
}
    return


Last edited by cevaps; 02-10-2012 at 16:04.
cevaps is offline
Send a message via ICQ to cevaps Send a message via MSN to cevaps
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-10-2012 , 16:20   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #7

You need to create weaponbox and not armoury_entity, and to link weapons into those weaponbox.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-10-2012 , 16:26   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #8

Also change

PHP Code:
new g_WeaponNames[19


PHP Code:
new g_WeaponNames[16
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
cevaps
Member
Join Date: Apr 2008
Location: Turkiye
Old 02-10-2012 , 18:59   Re: [REQ] Rewrite this plugin to HL1 please
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
You need to create weaponbox and not armoury_entity, and to link weapons into those weaponbox.
well, all i understand is "replace armoury_entity words with weaponbox", is that correct? because i don't know anything about writing plugins, all i can do is replacing things as what people says.
cevaps is offline
Send a message via ICQ to cevaps Send a message via MSN to cevaps
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 07:12.


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