Raised This Month: $ Target: $400
 0% 

find_ent_by_class problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shino
Senior Member
Join Date: May 2006
Old 05-22-2006 , 11:16   find_ent_by_class problems
Reply With Quote #1

here's my little issue:

Code:
public WeaponDrop(id) {     engclient_cmd(id,"drop","weapon_usp")     set_task(0.1,"DeleteUSP") } public DeleteUSP() {     new USP,szModel[33]     while ((USP = find_ent_by_class(-1, "weapon_usp")) != 0)     {         entity_get_string(USP, EV_SZ_model, szModel, 32)         if (equali(szModel, "models/w_usp.mdl"))         {             remove_entity(USP)             return PLUGIN_CONTINUE         }     }         return PLUGIN_CONTINUE }

as soon usp is dropped, the remove task performs and the server crashes. any suggestions?
shino is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-22-2006 , 12:03  
Reply With Quote #2

Yes. I don't recommend "coding" such thing - it's not that simple as MOST of the coders think. Just use fm_strip_user_gun from the Fakemeta Utilities or search for my strip_user_gun function.
VEN is offline
shino
Senior Member
Join Date: May 2006
Old 05-22-2006 , 14:35  
Reply With Quote #3

how should i then use this function, like this?
Code:
public WeaponDrop(id) {     fm_strip_user_gun(CSW_USP) } thanks!  :)
shino is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-22-2006 , 14:38  
Reply With Quote #4

You should specify the player's index:
Code:
fm_strip_user_gun(id, CSW_USP)
VEN is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 05-22-2006 , 19:18  
Reply With Quote #5

Code:
public DeleteUSP() {     new USP = find_ent_by_class(-1, "weapon_usp")     while(USP)     {         remove_entity(USP)         USP = find_ent_by_class(USP, "weapon_usp")     } }
However its best to use what VEN recommended! The above is only a portion of what you must code to remove weapons.
Orangutanz is offline
shino
Senior Member
Join Date: May 2006
Old 05-23-2006 , 14:09  
Reply With Quote #6

so, used fm_strip_user_gun as you said:
Code:
public WeaponDrop(players[]) {     new players[32],num,i     get_players(players,num)     for(i = 0; i <= num; i++) {         new id = players[i]         if (is_user_bot(id) && is_user_alive(id)) {             fm_strip_user_gun(id,CSW_AK47)             fm_strip_user_gun(id,CSW_AUG)             fm_strip_user_gun(id,CSW_AWP)             fm_strip_user_gun(id,CSW_C4)             fm_strip_user_gun(id,CSW_DEAGLE)             fm_strip_user_gun(id,CSW_ELITE)             fm_strip_user_gun(id,CSW_FAMAS)             fm_strip_user_gun(id,CSW_FIVESEVEN)             fm_strip_user_gun(id,CSW_FLASHBANG)             fm_strip_user_gun(id,CSW_G3SG1)             fm_strip_user_gun(id,CSW_GALI)             fm_strip_user_gun(id,CSW_GALIL)             fm_strip_user_gun(id,CSW_GLOCK18)             fm_strip_user_gun(id,CSW_HEGRENADE)             fm_strip_user_gun(id,CSW_M249)             fm_strip_user_gun(id,CSW_M3)             fm_strip_user_gun(id,CSW_M4A1)             fm_strip_user_gun(id,CSW_MAC10)             fm_strip_user_gun(id,CSW_MP5NAVY)             fm_strip_user_gun(id,CSW_P228)             fm_strip_user_gun(id,CSW_P90)             fm_strip_user_gun(id,CSW_SCOUT)             fm_strip_user_gun(id,CSW_SG550)             fm_strip_user_gun(id,CSW_SG552)             fm_strip_user_gun(id,CSW_SMOKEGRENADE)             fm_strip_user_gun(id,CSW_TMP)             fm_strip_user_gun(id,CSW_UMP45)             fm_strip_user_gun(id,CSW_USP)             fm_strip_user_gun(id,CSW_VEST)             fm_strip_user_gun(id,CSW_VESTHELM)             fm_strip_user_gun(id,CSW_XM1014)         }     }     return PLUGIN_CONTINUE }

but this is only performed on one bot. why?
shino is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-23-2006 , 14:36  
Reply With Quote #7

with get players you can get just alive bots with
Code:
new Players[32] , pnum get_players(Players , pnum , "ad")
So you don't need to check if they are alive or if they are bots.

Also you don't do <= pnum is < pnum

And don't use new id = ... inside of a loop its horrible practice. Causes more load.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
VEN
Veteran Member
Join Date: Jan 2005
Old 05-24-2006 , 02:43  
Reply With Quote #8

You can't strip vest(helm) and grenades with that function, it's for guns.
If you want to strip everything except knife why don't you use strip_user_weapons and then give_item knife?
VEN is offline
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 16:31.


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