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)

ThantiK 05-27-2004 01:09

nvm, I'm starting to get it now, its coming back to me...

although Yea, I'm looking directly @ csdm

ThantiK 05-27-2004 01:25

ok, I'm back to needing help.

How can I find out if the player touches a weapon and what weapon it is?...and how to put it in his inventory.

Its getting confusing now. I miss SmallEd.

BAILOPAN 05-27-2004 01:40

Rewrite this function so it compares against weapon models instead of weapon names:

Code:
//Change this to getWpFromModel(wp[]) getCSDMWpId(wp[]) {     if (equali(wp, "csdmw_p228")) {         return CSW_P228     } else if (equali(wp, "csdmw_scout")) {         return CSW_SCOUT     } else if (equali(wp, "csdmw_hegrenade")) {         return CSW_HEGRENADE     } else if (equali(wp, "csdmw_xm1014")) {         return CSW_XM1014     } else if (equali(wp, "csdmw_c4")) {         return CSW_C4     } else if (equali(wp, "csdmw_mac10")) {         return CSW_MAC10     } else if (equali(wp, "csdmw_aug")) {         return CSW_AUG     } else if (equali(wp, "csdmw_smokegrenade")) {         return CSW_SMOKEGRENADE     } else if (equali(wp, "csdmw_elite")) {         return CSW_ELITE     } else if (equali(wp, "csdmw_fiveseven")) {         return CSW_FIVESEVEN     } else if (equali(wp, "csdmw_ump45")) {         return CSW_UMP45     } else if (equali(wp, "csdmw_sg550")) {         return CSW_SG550     } else if (equali(wp, "csdmw_galil")) {         return CSW_GALIL     } else if (equali(wp, "csdmw_famas")) {         return CSW_FAMAS     } else if (equali(wp, "csdmw_usp")) {         return CSW_USP     } else if (equali(wp, "csdmw_glock18")) {         return CSW_GLOCK18     } else if (equali(wp, "csdmw_awp")) {         return CSW_AWP     } else if (equali(wp, "csdmw_mp5navy")) {         return CSW_MP5NAVY     } else if (equali(wp, "csdmw_m249")) {         return CSW_M249     } else if (equali(wp, "csdmw_m3")) {         return CSW_M3     } else if (equali(wp, "csdmw_m4a1")) {         return CSW_M4A1     } else if (equali(wp, "csdmw_tmp")) {         return CSW_TMP     } else if (equali(wp, "csdmw_g3sg1")) {         return CSW_G3SG1     } else if (equali(wp, "csdmw_flashbang")) {         return CSW_FLASHBANG     } else if (equali(wp, "csdmw_deagle")) {         return CSW_DEAGLE     } else if (equali(wp, "csdmw_sg552")) {         return CSW_SG552     } else if (equali(wp, "csdmw_ak47")) {         return CSW_AK47     } else if (equali(wp, "csdmw_knife")) {         return CSW_KNIFE     } else if (equali(wp, "csdmw_p90")) {         return CSW_P90     }         return 0 }

Then do this:
Code:
public pfn_touch(ptr, ptd) {    if ((ptd>=1 && ptd<=32) && is_user_connected(ptd)) {       new Model[32], wp, wpname[32]       entity_get_string(ptr, EV_SZ_model, Model, 31)       wp = getWpFromModel(Model)       get_weaponname(wp, wpname, 31)       give_item(ptd, wpname)    }    return PLUGIN_CONTINUE }

sorry I mixed up ptd and ptr in my original post

ThantiK 05-27-2004 02:15

Thanks bail.

Damn, lol, I wasn't really wanting ALL of that, but thanks!

I'll be posting other help topics soon...

Peli 05-27-2004 02:16

Very nice Bail. :)

ThantiK 05-27-2004 02:32

Wow, nice -- I could use this for putting a chicken model on the map and if you touch it you do something. Glow, llama, etc...lol

Thats sweet, thanks bailo

ThantiK 05-27-2004 02:50

I got a problem

I have AK, and Colt

I drop AK -- I switch to colt and it gives me AK back?

I can drop ak's and colts crazy around the map and it just keeps giving them to me even if I'm not on one...any way to delay this so I can drop it from inventory without picking it up again while in the air?

Also, is there a function to get a certain number of chars on the left of a string?...I know in VB its left(num, string) (Its so I can remove the entity once picked up...I gotta check if its a weapon_)

PM 05-27-2004 05:41

not sure about the first problem, but the second one:

Code:
new string[64]; // some native that fills string with data string[5] = 0; // string now contains only the first 5 characters returned by the native.

It works because strings in Small are (like strings in C) zero-terminated arrays of characters. So when you write a 0 to the index x, the string will only appear to have x characters (not x-1 because 0 is a valid index).

Note that you can't do this on constant strings ( "balbla"[4] = 0 :D ) and when you do this on a string, you modify it (VB's Left makes a new string, so the original string stays unchanged).

ThantiK 05-27-2004 07:33

Thanks PM...so I should end up with something like....

model[32] is "weapon_g3sg1"
model[6] = 0

model will then be "weapon_" after I do model[6] = 0?

Of course I'd be moving it to a new var to check it.

PM 05-27-2004 09:46

no, model will be "weapon" then. (6 chars)


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

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