AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get weapon info on ground, give weapon to player... (https://forums.alliedmods.net/showthread.php?t=2512)

ThantiK 06-07-2004 09:10

Get weapon info on ground, give weapon to player...
 
If I drop a weapon with 24/90 ammo, and its silenced, etc...

HOW would I go about giving THAT entity to a player...right now I'm just detecting if they run over a gun model and going the "give item" route...which isn't what I want.

Johnny got his gun 06-07-2004 12:34

Well to be picky the /90 is not part of the weapon, it's in your backpack. The number after the / is carried by player, the one before is the ammo in clip.

so, about your question. I have no clue. :-) I assume you try to give a specific weapon to a player if he runs over it, even if he already has a weapon of that type? (primary/secondary)

Other than that, you could just try to force the player to touch the weaponbox, and maybe he will pick it up even if he is a mile away.

This worked for me:

Code:
public faketouchcmd(id, level, cid) {     if (!cmd_access(id, level, cid, 3)) {         return PLUGIN_HANDLED     }     new arg[16]     read_argv(1, arg, 15)     new iToucher = str_to_num(arg)     read_argv(2, arg, 15)     new iTouched = str_to_num(arg)     console_print(id, "%d touches %d...", iToucher, iTouched)     fake_touch(iToucher, iTouched)     console_print(id, "Touch done.")     return PLUGIN_HANDLED }

Then entering weaponbox as 1st and player index as 2nd made user pick up that weapon if he didnt already have that type. Sending the arguments in the reverse order wouldn't work.

ThantiK 06-07-2004 13:56

Heres what I got so far...

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <fun> #define MAX_NAME_LENGTH 32 #define MAX_ENTITIES 1200 new bool:canpickup[33] public plugin_init() {     register_plugin("MultiWeapons","0.1","ThantiK")     register_clcmd("drop","cant_drop")     return PLUGIN_CONTINUE } public cant_drop(id) { canpickup[id] = false new ident[1] ident[0] = id set_task(0.4,"can_drop",2300+id,ident,1) return PLUGIN_CONTINUE } public can_drop(ident[]) { canpickup[ident[0]] = true return PLUGIN_HANDLED } public pfn_touch(ptr, ptd) { if ((ptd>=1 && ptd<=32) && is_user_connected(ptd)) { new Model[32], wp, wpname[32] if(!canpickup[ptd]) { return PLUGIN_CONTINUE } entity_get_string(ptr, EV_SZ_model, Model, 31) wp = getWpFromModel(Model) get_weaponname(wp, wpname, 31) give_item(ptd, wpname) } return PLUGIN_CONTINUE } getWpFromModel(wp[]) { if (equali(wp, "models/w_p228")) { return CSW_P228 } else if (equali(wp, "models/w_scout.mdl")) { return CSW_SCOUT } else if (equali(wp, "models/w_hegrenade.mdl")) { return CSW_HEGRENADE } else if (equali(wp, "models/w_xm1014.mdl")) { return CSW_XM1014 } else if (equali(wp, "models/w_c4.mdl")) { return CSW_C4 } else if (equali(wp, "models/w_mac10.mdl")) { return CSW_MAC10 } else if (equali(wp, "models/w_aug.mdl")) { return CSW_AUG } else if (equali(wp, "models/w_smokegrenade.mdl")) { return CSW_SMOKEGRENADE } else if (equali(wp, "models/w_elite.mdl")) { return CSW_ELITE } else if (equali(wp, "models/w_fiveseven.mdl")) { return CSW_FIVESEVEN } else if (equali(wp, "models/w_ump45.mdl")) { return CSW_UMP45 } else if (equali(wp, "models/w_sg550.mdl")) { return CSW_SG550 } else if (equali(wp, "models/w_galil.mdl")) { return CSW_GALIL } else if (equali(wp, "models/w_famas.mdl")) { return CSW_FAMAS } else if (equali(wp, "models/w_usp.mdl")) { return CSW_USP } else if (equali(wp, "models/w_glock18.mdl")) { return CSW_GLOCK18 } else if (equali(wp, "models/w_awp.mdl")) { return CSW_AWP } else if (equali(wp, "models/w_mp5navy.mdl")) { return CSW_MP5NAVY } else if (equali(wp, "models/w_m249.mdl")) { return CSW_M249 } else if (equali(wp, "models/w_m3.mdl")) { return CSW_M3 } else if (equali(wp, "models/w_m4a1.mdl")) { return CSW_M4A1 } else if (equali(wp, "models/w_tmp.mdl")) { return CSW_TMP } else if (equali(wp, "models/w_g3sg1.mdl")) { return CSW_G3SG1 } else if (equali(wp, "models/w_flashbang.mdl")) { return CSW_FLASHBANG } else if (equali(wp, "models/w_deagle.mdl")) { return CSW_DEAGLE } else if (equali(wp, "models/w_sg552.mdl")) { return CSW_SG552 } else if (equali(wp, "models/w_ak47.mdl")) { return CSW_AK47 } else if (equali(wp, "models/w_knife.mdl")) { return CSW_KNIFE } else if (equali(wp, "models/w_p90.mdl")) { return CSW_P90 } return 0 }

Thats how I go about doing it right now...
If the /90 is stored in backpack, I dont need to be worrying about that then. I just need to worry about the ammo that currently is in the weapon then. I dont get how to incorportate your way of using faketouch.


All times are GMT -4. The time now is 14:44.

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