Raised This Month: $ Target: $400
 0% 

CT PickUP C4 v1.6 ( updated again )


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   General Purpose       
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-24-2006 , 03:33   CT PickUP C4 v1.6 ( updated again )
Reply With Quote #1

Code:
/* Plugin generated by AMXX-Studio */

/*
   If there is only one C4 bomb in the game, you do not need the line "#define MORE_THAN_ONE_BOMB".

	Command : amx_ctpickupc4	; Effect cvar changing immediately,not till new round.

	Cvar	: amx_allowctpickupbomb ; Set it to 1, let CTs pick up C4; else CT can't pick up C4.
		: amx_allowctplantbomb  ; Set it to 0,CTs can not plant the C4 time bomb.
					  If you change this cvar to 1 only, it dose not effect until new round begins.
					  beacause the real state value stored at g_last...
	
	 Changing log: 
	 
	 v1.6  remove entity safest with VEN@amxx's help and change hudmessage
	 
	 v1.5  remove the real C4 entity from the world with VEN@amxx's help.
	 
	 v1.4  ....change a few
	 
	 v1.3  Just written in normal and released
	 
*/
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <engine> #include <fun> #define PLUGIN "CT PickUP C4" #define VERSION "1.6" #define AUTHOR "KinSprite" #define MORE_THAN_ONE_BOMB new g_allowctpickupbomb new g_lastcvarvalue new g_allowctplantbomb new g_lastallowctplantbomb new bool:allowctpickupbomb[33]=true public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_dictionary("ctpickupc4.txt")     register_concmd("amx_ctpickupc4","cmdallowctpickupbomb",ADMIN_IMMUNITY," Effect cvar changing immediately,not until new round.")     register_logevent("startnewround",2,"0=World triggered","1=Round_Start")     register_logevent("ct_dropbomb",3,"1=triggered")     register_touch("weaponbox", "player", "ctpickupbomb")     g_allowctpickupbomb = register_cvar("amx_allowctpickupbomb","0")     g_allowctplantbomb = register_cvar("amx_allowctplantbomb","1") }
Attached Files
File Type: txt ctpickupc4.txt (668 Bytes, 395 views)
File Type: sma Get Plugin or Get Source (ctpickupc4.sma - 1271 views - 5.4 KB)
kinsprite2 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-24-2006 , 04:16  
Reply With Quote #2

Quote:
Originally Posted by kinsprite2
use remove_entity_name("weapon_c4") ?
if there are more than one C4 in the game, what will happen ?
Thank you very much.
Here is the solution
Code:
remove_entity(find_ent_by_owner(-1, "weapon_c4", Ent))
VEN is offline
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-24-2006 , 07:03  
Reply With Quote #3

Quote:
Originally Posted by VEN
Quote:
Originally Posted by kinsprite2
use remove_entity_name("weapon_c4") ?
if there are more than one C4 in the game, what will happen ?
Thank you very much.
Here is the solution
Code:
remove_entity(find_ent_by_owner(-1, "weapon_c4", Ent))
Thank you very much. Now I understand.


Quote:
"weapon_c4" is actual C4 weapon entity, you should remove it after removing it's box in other case your code may be exploited.
And even if no one know how to exploit it, it's not nice since it leads to edicts overflow.
Now I remove C4 weapon before removing it's box. because after removing the box, there is no index of the box again. Or I must remove C4 weapon entity after it's box ? I think it is the same result.
kinsprite2 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-24-2006 , 08:53  
Reply With Quote #4

In theory it's doesn't matter but that's how engine do that.
It's necessary to pay attention while woking with entities especially in your case. You breaks entities "link" which may easily lead to server instability and even crash. Therefore i'd suggest you make your code as safe as possible.

Code:
new c4 = find_ent_by_owner(-1, "weapon_c4", Ent) remove_entity(Ent) remove_entity(c4)

There are one more important trick - "natural" entity deleting (remark: me and T(+)rget discovered that method independently).
Here is the stock wich i usually use:
Code:
stock kill_entity(id) {     entity_set_int(id, EV_INT_flags, entity_get_int(id, EV_INT_flags)|FL_KILLME) }

So in your case safest entity pair deleting would be something like this:
Code:
new c4 = find_ent_by_owner(-1, "weapon_c4", Ent) entity_set_int(Ent, EV_INT_flags, entity_get_int(Ent, EV_INT_flags)|FL_KILLME) entity_set_int(c4, EV_INT_flags, entity_get_int(c4, EV_INT_flags)|FL_KILLME)

Or just put the stock somewhere in your code (outside other functions of course) and then the code above would looks like:
Code:
new c4 = find_ent_by_owner(-1, "weapon_c4", Ent) kill_entity(Ent) kill_entity(c4)
VEN is offline
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-24-2006 , 09:56  
Reply With Quote #5

Quote:
Originally Posted by VEN
.....
Quote:
With your help, I know a little about how engine delete them now. Also,I will rewrite the hudmessage.
Thanks very much.
I have updated it .
kinsprite2 is offline
Switchie
Senior Member
Join Date: Mar 2006
Location: Belgium
Old 03-25-2006 , 09:37  
Reply With Quote #6

ok i will test this one now
__________________
Switchie is offline
Switchie
Senior Member
Join Date: Mar 2006
Location: Belgium
Old 03-25-2006 , 09:49  
Reply With Quote #7

L 03/25/2006 - 15:454: -------- Mapchange to de_dust2 --------
L 03/25/2006 - 15:455: [AMXX] Plugin "c4.amxx" failed to load: Plugin uses an unknown function (name "get_pcvar_num") - check your modules.ini.

What am i doing wrong then

Ven you said you now a working one and i can find it plz pm me then

Greetz
__________________
Switchie is offline
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-25-2006 , 10:18  
Reply With Quote #8

Quote:
Originally Posted by Switchie
L 03/25/2006 - 15:454: -------- Mapchange to de_dust2 --------
L 03/25/2006 - 15:455: [AMXX] Plugin "c4.amxx" failed to load: Plugin uses an unknown function (name "get_pcvar_num") - check your modules.ini.

What am i doing wrong then

Ven you said you now a working one and i can find it plz pm me then

Greetz

get_pcvar_num(), a function in AMXX 1.70 . Also in AMXX 1.70, register_cvar() return a value
kinsprite2 is offline
Switchie
Senior Member
Join Date: Mar 2006
Location: Belgium
Old 03-25-2006 , 10:21  
Reply With Quote #9

yeah but 1.70 is bugged i did go back to 1.60

waiting for 1.71

thx for the help
__________________
Switchie 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 12:52.


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