Raised This Month: $51 Target: $400
 12% 

Removing weapon entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sub
Senior Member
Join Date: Nov 2004
Location: Morristown, New Jersey
Old 03-03-2007 , 12:40   Removing weapon entities
Reply With Quote #1

Well I am making a gunshop for svencoop. The goal of my plugin part here, is to give the player and only that player a certain weapon (see example). The problem is, when I give the person a weapon, it also spawns the same weapon beneath them. I do not want other players to be able to get the weapon that that person just purchased. MyStIcSsJgOkU4 tried helping me, but now the problem is, the server crashes when ever a weapon is purchased. Here is the code

Code:
        case 4: {//5             if(money[id] < 200)             {                 client_print(id,print_chat,"[GunShop] You cannot afford that!")                 return PLUGIN_HANDLED             }             else             {                 client_print(id,print_chat,"[GunShop] Your purchased a Barnacle")                 money[id] -= 200                 give_item(id,"weapon_grapple")                 find_gun_ent(id)             }         }         case 9: { // 0                     }     }     return PLUGIN_CONTINUE } //Removes guns when one is spawned public find_gun_ent(id) //Trigger this AFTER the weapon is given RIGHT AWAY! {     new ent, classname[64], Float:radius = 64.0, Float:origin[3]     entity_get_vector(id,EV_VEC_origin,origin)     while((ent = find_ent_in_sphere(ent,origin,radius)) != 0)     {         entity_get_string(ent,EV_SZ_classname,classname,63)         if(containi(classname,"weapon_") != -1) //if it does not return -1 (NONE FOUND)         {             remove_entity(ent)         }     }     return 0 }

This is only an excerpt, but this is an example of the problem, and its not only for this weapon, but for all weapons.
__________________
[img]http://img409.**************/img409/1079/sublimefd6.png[/img]
I Have Owned City14 - City17 - Zackscity
sub is offline
Send a message via AIM to sub Send a message via MSN to sub
sub
Senior Member
Join Date: Nov 2004
Location: Morristown, New Jersey
Old 03-04-2007 , 20:18   Re: Removing weapon entities
Reply With Quote #2

Yea can someone help at all?
__________________
[img]http://img409.**************/img409/1079/sublimefd6.png[/img]
I Have Owned City14 - City17 - Zackscity
sub is offline
Send a message via AIM to sub Send a message via MSN to sub
Drak
Veteran Member
Join Date: Jul 2005
Old 03-04-2007 , 20:22   Re: Removing weapon entities
Reply With Quote #3

I noticed the weapons that are dropped by a player, are 'un-readable' I can't get it's entid, or any information about it once so ever. But the spawned weapons entitys (In the map) seems to work.
Drak is offline
Send a message via MSN to Drak
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-04-2007 , 21:11   Re: Removing weapon entities
Reply With Quote #4

Players have a weapon_* entity that follows them around for every weapon that they have in their inventory. So you're attempting to delete a weapon straight from a player, which is why it is crashing. Try checking the found weapon_* entities and making sure that their pev_owner (or EV_ENT_owner) isn't isn't a player entity.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 03-04-2007 , 21:43   Re: Removing weapon entities
Reply With Quote #5

http://forums.alliedmods.net/showpos...62&postcount=2
Found that.
Drak is offline
Send a message via MSN to Drak
VEN
Veteran Member
Join Date: Jan 2005
Old 03-05-2007 , 02:52   Re: Removing weapon entities
Reply With Quote #6

This isn't the best solution though. Some users say that it's potential to crash.

Safe method will be to force weaponbox entity think.

More explanations about "non-natural" weapon deletion is here: http://forums.alliedmods.net/showpos...1&postcount=10

Weaponbox deletion example is here: http://forums.alliedmods.net/showpos...71&postcount=1 (see the attachment).

Also there are some stock functions that may help in this situation:
fm_remove_weaponbox
fm_get_weaponbox_type
fm_strip_user_gun

See Fakemeta Utilities for such functions and more.

Last edited by VEN; 03-05-2007 at 03:03.
VEN is offline
Oskar
BANNED
Join Date: Jan 2007
Location: Slöinge, Falkenberg, Hal
Old 03-05-2007 , 05:31   Re: Removing weapon entities
Reply With Quote #7

I hope it will be much easier to script for Sven Co-op when the SC module is released.
Oskar is offline
Send a message via MSN to Oskar
sub
Senior Member
Join Date: Nov 2004
Location: Morristown, New Jersey
Old 03-05-2007 , 15:24   Re: Removing weapon entities
Reply With Quote #8

Yea that would be great Oskar, thanks everyone, ill see if I can get things to work.
Edit: Im not trying to strip the gun, but delete the gun from the ground that is also spawned when the user is give_itemed
__________________
[img]http://img409.**************/img409/1079/sublimefd6.png[/img]
I Have Owned City14 - City17 - Zackscity

Last edited by sub; 03-05-2007 at 15:25. Reason: Addition to statement
sub is offline
Send a message via AIM to sub Send a message via MSN to sub
VEN
Veteran Member
Join Date: Jan 2005
Old 03-05-2007 , 15:31   Re: Removing weapon entities
Reply With Quote #9

What is its classname?
VEN is offline
sub
Senior Member
Join Date: Nov 2004
Location: Morristown, New Jersey
Old 03-05-2007 , 20:43   Re: Removing weapon entities
Reply With Quote #10

well....
• weapon_357
• weapon_9mmAR
• weapon_9mmhandgun
• weapon_crossbow
• weapon_crowbar
• weapon_egon
• weapon_gauss
• weapon_handgrenade
• weapon_hornetgun
• weapon_rpg
• weapon_satchel
• weapon_shotgun
• weapon_snark
• weapon_tripmine
• weaponbox
- weapon_grapple
- weapon_medkit
- weapon_minigun
- weapon_pipewrench
- weapon_sniperrifle
- weapon_uzi
- weapon_uziakimbo
__________________
[img]http://img409.**************/img409/1079/sublimefd6.png[/img]
I Have Owned City14 - City17 - Zackscity
sub is offline
Send a message via AIM to sub Send a message via MSN to sub
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 18:35.


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