Raised This Month: $213 Target: $400
 53% 

Flag


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
[email protected]
Member
Join Date: May 2010
Location: Serbia
Old 08-02-2011 , 15:23   Flag
Reply With Quote #1

Description: This plugin allows players to place a flag when they reach a enemy spawn. When player reaches enemy spawn, he need's to press E (+use) and he will get X frags ( controled by cvar ). In order to place a flag, player need's to hold knife.

Only one flag can be placed per round!

Cvars:
amx_flag_reward - default 3

Screenshots:
Not at enemy spawn
Somebody placed flag before you
You aren't holding knife
You placed a flag

Credits:
Arkshine - Ham_ObjectCaps thing
Ovidius - Ham_ObjectCaps and converted all to engine ( no fm )

Note: Player will get frags on round end
Note2: This is my first plugin posted on Allied Modders Forum

Place flag.mdl in your models floder ( cstrike/models )
Attached Files
File Type: zip model.zip (16.5 KB, 104 views)
File Type: sma Get Plugin or Get Source (flag.sma - 595 views - 2.2 KB)

Last edited by [email protected]; 08-02-2011 at 20:28.
Sp@jk is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-02-2011 , 15:44   Re: Flag
Reply With Quote #2

That's not really a good method to detect if you hold +use, another plugin/module could be used this sound for another thing.
__________________
Arkshine is offline
[email protected]
Member
Join Date: May 2010
Location: Serbia
Old 08-02-2011 , 18:07   Re: Flag
Reply With Quote #3

can you please give me a better way
Sp@jk is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 08-02-2011 , 18:24   Re: Flag
Reply With Quote #4

Use FM_CmdStart instead and hook their the USE button. There are much topic about that in the scripting help section, look there.
__________________
Accepting paid work for clans and communities. !Plugins & Models!
Don't hesitate to contact me.
bibu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-02-2011 , 18:40   Re: Flag
Reply With Quote #5

No.

Hook Ham_ObjectCaps, it will be called when +use is holding. Then, check pev_button or get_user_button if it contains IN_USE (not sure if it's even needed). FM_CmdStart is called a lot of time and all the time, really not a good way.
__________________

Last edited by Arkshine; 08-02-2011 at 18:48.
Arkshine is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 08-02-2011 , 19:19   Re: Flag
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
Hook Ham_ObjectCaps..
PHP Code:
learned_again_something_new[id]++ 
__________________
Accepting paid work for clans and communities. !Plugins & Models!
Don't hesitate to contact me.
bibu is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 08-02-2011 , 19:56   Re: Flag
Reply With Quote #7

hm, try this, i'm not pro, but i think it will work..
removed fakemeta, cstrike, added ham
Code:
#include <amxmodx>
#include <hamsandwich>
#include <engine>

new g_planted, p_reward 
new g_model[] = "models/flag.mdl" 

public plugin_init()
{
	register_plugin("Flag Remaked","1.0","[email protected]") 
	register_event("HLTV","newRound","a","1=0","2=0")
	RegisterHam( Ham_ObjectCaps , "player", "Forward_ObjectCaps" )
	p_reward=register_cvar("amx_flag_reward","3") 
}

public plugin_precache()
	precache_model(g_model)

public newRound()
{
	g_planted=0
	new iEnt = find_ent_by_class(-1,"flag")
	while(iEnt > 0) 
	{
		remove_entity(iEnt)
		iEnt = find_ent_by_class(iEnt, "flag");	
	}
}

public Forward_ObjectCaps(id)
{
	if (!is_user_connected(id) || !is_user_alive(id))
		return HAM_SUPERCEDE

	if(!g_planted)
	{
		new name[24]
		switch(get_user_team(id))
		{
			case 1:
				name="info_player_start"
			case 2:
				name="info_player_deathmatch"
		}
		new entlist[33];
		new numfound = find_sphere_class(id,name, 50.0, entlist, 32);
		if(numfound>0)
		{
			if(get_user_weapon(id)==CSW_KNIFE)
			{
				new Float:Origin[3]
				entity_get_vector(id,EV_VEC_origin,Origin)
				new flag = create_entity("info_target");
				entity_set_string(flag ,EV_SZ_classname, "flag");
				entity_set_origin(flag,Origin);
				entity_set_model(flag, g_model) 
				entity_set_float(flag,EV_FL_framerate,1.0)
				entity_set_int(flag,EV_INT_sequence,1)
				new Float:frags
				entity_set_float(id, EV_FL_frags, frags)
				drop_to_floor(flag)
				entity_set_float(id, EV_FL_frags,frags+float(get_pcvar_num(p_reward)))
				client_print(id,print_center,"Flag placed!")
				new nick[32]
				get_user_name(id,nick,31)
				client_print(0,print_chat,"[FLAG] %s placed a flag and earned %i frags",nick,get_pcvar_num(p_reward))
				g_planted=1
			}
			else
				client_print(id,print_center,"You must hold the knife!")
		}
		else
			client_print(id,print_center,"You need to be on enemy spawn!")
	}
	else
		client_print(id,print_center,"Sorry, but flag has already been placed.")
	
	return HAM_IGNORED;
}
OvidiuS is offline
Send a message via Skype™ to OvidiuS
[email protected]
Member
Join Date: May 2010
Location: Serbia
Old 08-02-2011 , 20:29   Re: Flag
Reply With Quote #8

tested Ovidius's code and it's working added Credits
Sp@jk is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-03-2011 , 03:46   Re: Flag
Reply With Quote #9

Woow, don't just copy his code like that without even understand...

if (!is_user_connected(id) || !is_user_alive(id)) => is_user_alive already checks is user is connected.
return HAM_SUPERCEDE => What is the point to supercede here ?

so, is_user_alive + _IGNORED.
__________________
Arkshine is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 08-03-2011 , 04:33   Re: Flag
Reply With Quote #10

hm didn't know that for is_user_alive, it soo obvious xD
thank's for correcting me

Quote:
Originally Posted by bibu View Post
PHP Code:
learned_again_something_new[id]++ 
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Reply


Thread Tools
Display Modes

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 05:23.


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