AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   vexd_pfntouch & Weapons on ground... (https://forums.alliedmods.net/showthread.php?t=2082)

DopeFish 05-27-2004 10:22

I had a similar problem with my plugin (custom items that can be dropped and picked up). I simply made a bool:canpickup[33] that I set to false for the player when someone drops something. It is set back to true 0.3 seconds later (item is dropped with a 400 velocity in the direction the player is aiming, you may need to alter the timing if the weapon is dropped faster or slower).
The top of public pfn_touch(ptr, ptd) looks like this for my plugin:
Code:
public pfn_touch(ptr, ptd) {      new itemClassName[MAX_NAME_LENGTH], playerClassname[MAX_NAME_LENGTH]      entity_get_string(ptr, EV_SZ_classname, itemClassName, MAX_NAME_LENGTH-1);      entity_get_string(ptd, EV_SZ_classname, playerClassname, MAX_NAME_LENGTH-1)      if(equal(itemClassName,"wc3item") && equal(playerClassname,"player")) {           if(!canpickup[ptd])                return PLUGIN_CONTINUE . . .

viola, no more premature picking up stuff.

ThantiK 05-28-2004 04:59

DopeFish, how do I set that per-player?...how do I find when the user drops and item to be able to block it?

Another question...is there a way to get entity data to get ACTUALLY what is on the ground? -- say, a colt on ground has silencer on it, and 13 bullets, and 40 in the spare clips?...I want to give the player THAT weapon...and if they run out they can drop the empty item?

DopeFish 05-28-2004 05:27

in my case it was easy since they had to use a menu command or a bind to drop the item, you may need to hook the drop command. this code snippet may help you further:

Code:
#define MAX_NAME_LENGTH 32 new bool:canpickup[33] public plugin_init() {      register_clcmd("drop","cmd_drop")      register_event("ResetHUD", "new_round", "b") } public cmd_drop(id) {      canpickup[id] = false      new ident[1]      ident[0] = id      set_task(0.3,"safedrop",2300+id,ident,1)      return PLUGIN_CONTINUE } public safedrop(ident[]) {         canpickup[ident[0]] = true         return PLUGIN_HANDLED } public new_round(id){      canpickup[id] = true } public pfn_touch(ptr, ptd) {      new itemClassName[MAX_NAME_LENGTH], playerClassname[MAX_NAME_LENGTH]      entity_get_string(ptr, EV_SZ_classname, itemClassName, MAX_NAME_LENGTH-1);      entity_get_string(ptd, EV_SZ_classname, playerClassname, MAX_NAME_LENGTH-1)      itemClassName[6]=0      if(equal(itemClassName,"weapon") && equal(playerClassname,"player")) {           if(!canpickup[ptd])                return PLUGIN_CONTINUE           // player is touching weapon and it is not the one he just dropped           // add code here ;) (like setting the itemClassName back to the full name)           entity_get_string(ptr, EV_SZ_classname, itemClassName, MAX_NAME_LENGTH-1);        }      return PLUGIN_CONTINUE }

I wrote it off the top of my head and copied some stuff from my plugins so some things may be needless, but I think you'll get the generel idea how it works. hope this helps.

The second part of the question is a little harder for me since I've never coded that kind of stuff, "Jhonny got his gun" would definatly know an answer to that question.

ThantiK 05-28-2004 05:47

wow, thanks.

Forgot about the register_clcmd function...(doh!)

I used to work/learn amx 24/7 but I've been working on websites, etc and AMXX .16 was unstable for me so I went back to old stuff...and I'm starting again working on amxx plugins anticipating the .20 release.

ThantiK 05-28-2004 06:10

btw, thanks guys...

heres my code so far.

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <fun> #define MAX_NAME_LENGTH 32 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.3,"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)) { //can I just do another "&& canpickup[ptd]" to get rid of that if function? 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 }

My only problems now are getting rid of the entity that just got picked up, and making sure the gun has the same ammo it got dropped with...and making a menu frontend to make sure they can buy multiple weapons and also pick them up.

Maybe I should make a cvar for multi_canpickup, multi_canbuy?

ts2do 05-29-2004 18:23

nooooo u dont get rid of the entity...u just make it invisible and movetype_follow and aiment as the player

ThantiK 05-29-2004 18:35

wtf, you just lost me...

BAILOPAN 05-29-2004 18:58

you have to remove the weapon off the ground once you give it to the player.

there is code in CSDM to show you how to do this: look in safe_rment and replaceWeapon (just strip out the code that creates a fake weapon to replace it)


All times are GMT -4. The time now is 10:58.

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