Raised This Month: $ Target: $400
 0% 

.ready


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
javf
Junior Member
Join Date: Mar 2009
Old 09-16-2010 , 09:08   .ready
Reply With Quote #1

not good if I can help with this plugin, I need
I edit this plugin so that they do not put. ready
in 2 min you out of the server

sorry for my english use google traductor xD

Code:
// Rukia: YAP Ready code

//	Ready mode is very intuitive.
//	In reality, we just wait for everyone to ready up, and restore state
//	So, in simplest form, "ready" is a vote that can last an infinitely long time. Very simple.

#include <amxmodx>
#include <amxmisc>

#include <yap_const>
#include <yap_stocks>
#include <yap_natives>
#include <yap_forwards>
#include <yap_modspecific>

new const plugin_author[] = "Twilight Suzuka"
new const plugin_name[] = "YAP-RDY"
new const plugin_version[] = "0.0.1"

CREATE_GEN_FORW_ID(pug_forward_ready);

public plugin_init()
{
	// Rukia: Plugin definition
	new p_id = register_plugin(plugin_name,plugin_version,plugin_author);

	register_dictionary("yap.txt")
	register_dictionary("yap_ready.txt")

	register_pug_clcmd("ready","ready_up",_,"Tells the server player is ready")
	register_pug_clcmd("notready","ready_down",_,"Tells the server player is not ready")

	register_pug_admincmd("forceready","cmd_forceready",PUG_CMD_LVL,"<name or #userid> Forces a client to be ready")
	register_pug_admincmd("forceunready","cmd_forceunready",PUG_CMD_LVL,"<name or #userid> Forces a client to be unready")

	pug_forward_ready = create_gen_forward("pug_all_ready",p_id,get_func_id("pug_ready_handler") )

	//parse_header("BOE-E",pug_header,5)
	register_event("ResetHUD","pug_keepup_menu","b")

	pug_change_display(get_func_id("pug_ready_display_really") , -1)
}

// Rukia: Ready variables
new pug_players_ready[33]
new pug_total_ready = 0;

// Rukia: make sure we keep up menu as much as possible, so that it updates correctly
public client_connect(id) set_task(15.0,"pug_keepup_menu")
public client_putinserver(id) pug_keepup_menu()

// Rukia: If someone disconnects, we need to take them out of the line up, and make sure that everything is cool
public client_disconnect(id)
{
	if( GET_PUG_STAGE() != PUG_STAGE_READY ) return;

	if(pug_players_ready[id]) 
	{
		pug_players_ready[id] = 0;
		pug_total_ready--;
	}
	
	pug_keepup_menu()
}

// Rukia: Make sure to change HUD when people change names
public client_infochanged(id) set_task(0.1,"pug_keepup_menu")

// Rukia: Dynamic native code
public plugin_natives()
{
	register_native("pug_ready_players","native_pug_ready_players")
	register_native("register_ready_display","native_register_ready_display")
}

public native_pug_ready_players(id,params)
{
	new p_id = get_param(2)
	pug_ready_players(get_param(1),(p_id == -1) ? id : p_id)
}

public native_register_ready_display(id,params)
{
	new p_id = get_param(2)
	pug_change_display(get_param(1),(p_id == -1) ? id : p_id)
}

public cmd_forceready(id,level,cid)
{
	if (!cmd_access(id, level, cid, 2) ) return PLUGIN_HANDLED;

	static victim_arg[32]
	read_argv(1,victim_arg,31)

	if(equali(victim_arg,"all")) return cmd_force_all_ready(id);

	new target = cmd_target(id,victim_arg,1)
	if (!target) return PLUGIN_HANDLED

	pug_admin_cmd_c(id,"PugForceReady","PUG_FORCE_READY",target,ready_up(target));
	return PLUGIN_HANDLED;
}

public cmd_forceunready(id,level,cid)
{
	if (!cmd_access(id, level, cid, 2) ) return PLUGIN_HANDLED;

	static victim_arg[32]
	read_argv(1,victim_arg,31)

	if(equali(victim_arg,"all")) return cmd_force_all_unready(id);

	new target = cmd_target(id,victim_arg,1)
	if (!target) return PLUGIN_HANDLED

	pug_admin_cmd_c(id,"PugForceUnReady","PUG_FORCE_UNREADY",target,ready_down(target));
	return PLUGIN_HANDLED;
}

public cmd_force_all_ready(id)
{
	static Players[32]
	new playerCount, i
	get_players(Players, playerCount, "h")

	for (i=0; i<playerCount; i++) ready_up(Players[i])

	pug_admin_cmd(id,"PugForceAllReady","PUG_FORCE_ALL_READY",1);
	return PLUGIN_HANDLED
}

public cmd_force_all_unready(id)
{
	static Players[32]
	new playerCount, i
	get_players(Players, playerCount, "h")

	for (i=0; i<playerCount; i++) ready_down(Players[i])

	pug_admin_cmd(id,"PugForceAllUnReady","PUG_FORCE_ALL_UNREADY",1);
	return PLUGIN_HANDLED
}


// Rukia: Ready code

public pug_ready_funcid;
public pug_ready_plugin_id;
public pug_ready_prev_stage;

// Rukia: save the handler function
pug_ready_players(f_id, p_id = -1)
{
	if(GET_PUG_STAGE() == PUG_STAGE_READY) return;
	pug_ready_funcid = f_id;
	pug_ready_plugin_id = p_id;

	pug_start_ready_players()
}

// Rukia: Save state, sub in our own, and start the ready!
public pug_start_ready_players()
{
	if(GET_PUG_STATUS() != PUG_STATUS_LIVE) return pug_set_pause_call(get_func_id("pug_start_ready_players"));

	pug_ready_prev_stage = GET_PUG_STAGE();
	SET_PUG_STAGE(PUG_STAGE_READY);
	SET_PUG_STATUS(PUG_STATUS_WAITING);

	arrayset(pug_players_ready,0,33)
	pug_total_ready = 0;

	pug_msg_tmp_empty(0,"PUG_READY_UP")
	pug_keepup_menu()

	return 1;
}

public ready_up(id)
{
	if((pug_players_ready[id] == 1) 
		|| GET_PUG_STATUS() != PUG_STATUS_WAITING || GET_PUG_STAGE() != PUG_STAGE_READY 
		|| is_user_hltv(id) 
	) 	
	{
		return pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED")
	}

	pug_players_ready[id] = 1;
	pug_total_ready++;

	static name[32]
	get_user_name(id,name,31)
	client_print(0,print_chat,"%s %L",pug_header, LANG_PLAYER, "PUG_PLAYER_READYED",name);

	pug_check_ready();

	return PLUGIN_HANDLED;
}

public ready_down(id)
{
	if((pug_players_ready[id] == 0) 
		|| GET_PUG_STATUS() != PUG_STATUS_WAITING || GET_PUG_STAGE() != PUG_STAGE_READY 
		|| is_user_hltv(id)
	)
	{
		return pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED")
	}

	pug_players_ready[id] = 0;
	pug_total_ready--;

	pug_ready_display(9999.0)

	static name[32]
	get_user_name(id,name,31)
	client_print(0,print_chat,"%s %L",pug_header, LANG_PLAYER, "PUG_PLAYER_UNREADYED",name);

	return PLUGIN_HANDLED;
}

public pug_keepup_menu()
{
	if(GET_PUG_STAGE() == PUG_STAGE_READY)
	{
		pug_ready_display(99999.0)
	}
}
	

public pug_check_ready()
{
	if(pug_total_ready >= GET_CVAR_MINPLAYERS() )
	{
		pug_ready_display(1.0)
		pug_ready()
	}
	else pug_ready_display(9999.0)
}


public pug_ready_display_funcid
public pug_ready_display_plugin_id

public pug_change_display(f_id, p_id)
{
	pug_ready_display_funcid = f_id;
	pug_ready_display_plugin_id = p_id;
	pug_keepup_menu()
}

// Rukia: NOTE TO DO: Allow for subbing in own ready display in other plugins.
public pug_ready_display(Float:hold_time)
{
	callfunc_begin_i(pug_ready_display_funcid,pug_ready_display_plugin_id)
	callfunc_push_float(hold_time)
	callfunc_end()
}

public pug_ready_display_really(Float:hold_time)
{
	static readys[1056], notreadys[1056], name[32]

	readys[0] = '^0'
	notreadys[0] = '^0'

	static Players[32]
	new playerCount, i, player
	get_players(Players, playerCount, "ch")
	for (i=0; i<playerCount; i++)
	{
		player = Players[i]
		get_user_name(player,name,31)

		if(pug_players_ready[player]) format(readys,1054,"%s%s^n",readys,name)
		else format(notreadys,1054,"%s%s^n",notreadys,name)
	}

	new minplayers = GET_CVAR_MINPLAYERS()

	set_hudmessage(0, 255, 0, 0.8, 0.07, 0, 0.0, hold_time, 0.0, 0.0, 3)
	show_hudmessage(0,"Player Not Ready:",pug_get_players() - pug_total_ready,minplayers )

	set_hudmessage(0, 255, 0, 0.8, 0.50, 0, 0.0, hold_time, 0.0, 0.0, 2)
	show_hudmessage(0,"Player Ready:",pug_total_ready,minplayers)

	set_hudmessage(255, 255, 225, 0.80, 0.53, 0, 0.0, hold_time, 0.0, 0.0, 1)
	show_hudmessage(0,readys,1055)

	set_hudmessage(255, 255, 225, 0.80, 0.10, 0, 0.0, hold_time, 0.0, 0.0, 4)
	show_hudmessage(0,notreadys,1055)
}

// Rukia: We are ready to go! Tell everyone!
public pug_ready()
{
	if(GET_PUG_STAGE() != PUG_STAGE_READY) return 0;
	else if(GET_PUG_STATUS() != PUG_STATUS_WAITING) return pug_set_pause_call(get_func_id("pug_ready"));

	execute_gen_forward(pug_forward_ready)
	return 1;
}

// Rukia: Restore state, tell everyone we are ready, and call the handler function!
public pug_ready_handler()
{
	if(GET_PUG_STATUS() != PUG_STATUS_WAITING) return pug_set_pause_call(get_func_id("pug_ready_handler"));

	SET_PUG_STATUS(PUG_STATUS_LIVE);
	SET_PUG_STAGE(pug_ready_prev_stage);

	pug_msg_tmp_empty(0,"PUG_IS_READY")

	callfunc_begin_i(pug_ready_funcid,pug_ready_plugin_id)
	callfunc_end()

	return 1;
}

Last edited by javf; 09-16-2010 at 09:29.
javf is offline
Alex.
SourceMod Donor
Join Date: Sep 2010
Location: England
Old 09-16-2010 , 12:41   Re: .ready
Reply With Quote #2

This is the SourceMod forum. Try https://forums.alliedmods.net/forumdisplay.php?f=11.

Last edited by Alex.; 09-16-2010 at 12:51.
Alex. 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 19:29.


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