Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
|
07-20-2014
, 15:22
Weapons War (Developer Mode)
|
#4
|
Weapons War
(Developer Mode)
cs_war.inc file?
So, this is the list of natives and forwards:
-->
PHP Code:
/* * Return whether current round is war round */ native cs_is_war_round();
/* * Return current war name * param const szWarName[] - the name of current weapon war round * param iLen - maximum size of buffer */ native cs_current_war(const szWarName[], iLen);
/* * Return last war name * param const szWarName[] - the name of current weapon war round * param iLen - maximum size of buffer */ native cs_last_war(const szWarName[], iLen);
/* * Return war ID * param const szWarName[] - the name of weapon war round * param const szWarID[] - the name of weapon ID */ native cs_war_set(const szWarName[], const szWarID[]);
/** * Return auto-start war round */ native cs_start_war();
/** * Return auto-start war vote * param Float:fVoteTime - the durations for voting */ native cs_start_vote(Float:fVoteTime);
/** * Return point leader * param id - ID of client */ native cs_is_point_leader(id);
/****************************** * Forwards *******************************/
/** * This is called during a war round is started */ forward cs_fw_war_start();
/** * This is called during a war round is end */ forward cs_fw_war_end();
/** * This is called during a war vote is started */ forward cs_fw_vote_start();
/** * This is called during a war vote is end */ forward cs_fw_vote_end();
For example, just download the war_trail.sma file to see how to use them. ;)
Custom Weapon War?
Just see custom_war.sma file. ;)
-->
PHP Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <cs_war>
// Configure admin flag #define ADMIN_FLAG ADMIN_VOTE
// String new g_sCurrentWar[32]
public plugin_init() { register_plugin("Custom War", "1.0", "zmd94") // In this example, I just show how to start a custom war using a command. // If you want to start the custom war automatically, just comment to learn. // We also can add more that 1 custom war. ;) register_clcmd("say /cus", "clcmd_custom_war") register_clcmd("say_team /cus", "clcmd_custom_war") register_clcmd("say /cvote", "clcmd_custom_vote") register_clcmd("say_team /ccvote", "clcmd_custom_vote") RegisterHam(Ham_Spawn, "player", "cs_cus_PlayerRespawn", 1) register_forward(FM_TraceLine, "forward_traceline", 1) }
public clcmd_custom_war(id) { // Register our custom war // Just use cs_war_set(const szWarName[], const szWarID[]) native. // const szWarName[] - the name of weapon war round // const szWarID[] - the name of weapon ID // In this example, I choose to give all players AK-47. ;) cs_war_set("Head Hunter", "weapon_ak47") // Other than this, you also can set random custom war // and just using pcvar. // Just comment if you want to learn. ;) // Then, start our custom war // Just use cs_start_war() native cs_start_war() }
public clcmd_custom_vote(id) { // Register our custom war vote // Just use cs_war_set(const szWarName[], const szWarID[]) native. // const szWarName[] - the name of weapon war round // const szWarID[] - the name of weapon ID // In this example, I choose to give all players AK-47. ;) cs_war_set("Head Hunter", "weapon_ak47") // Other than this, you also can set random custom war // and just using pcvar. // Just comment if you want to learn. ;) // Then, start our custom war // Just use cs_start_vote(Float:fVoteTime) native // Float:fVoteTime - the durations for voting // Vote for 30s cs_start_vote(30.0) }
// War round is start. public cs_fw_war_start() { // Just use native cs_current_war(const szWarName[], iLen) inside cs_fw_war_start() forward. ;) cs_current_war(g_sCurrentWar, charsmax(g_sCurrentWar)) if(equal(g_sCurrentWar, "Head Hunter")) { client_print(0, print_chat, "[WW] Run everyone!") } }
public cs_cus_PlayerRespawn(id) { if(cs_is_war_round() && equal(g_sCurrentWar, "Head Hunter")) { client_print(id, print_chat, "[WW] Now is Head Hunter round!") } }
// Credit to ConnorMcLeod // This will only allow player to dealt a damage if their bullets hit enemies's head. ;) public forward_traceline(Float:v1[3], Float:v2[3], noMonsters, pentToSkip) { // If now is not war round. ;) if(!cs_is_war_round() || !is_user_alive(pentToSkip)) return FMRES_IGNORED if(equal(g_sCurrentWar, "Head Hunter")) { static entity2 ; entity2 = get_tr(TR_pHit) if(!is_user_alive(entity2) || pentToSkip == entity2) return FMRES_IGNORED
if(get_tr(TR_iHitgroup) != 1) { set_tr(TR_flFraction,1.0) return FMRES_SUPERCEDE } } return FMRES_IGNORED }
How to use the API?
PHP Code:
/////////////////////////////////////////////////////////////// // Below is how to get current weapon war round as global string?
// String new g_sCurrentWar[32]
public cs_fw_war_start() { // Just use native cs_current_war(const szWarName[], iLen) inside cs_fw_war_start() forward. ;) cs_current_war(g_sCurrentWar, charsmax(g_sCurrentWar)) }
public cs_fw_vote_start() { if(equal(g_sCurrentWar, "Auto-Shotgun")) { client_print(0, print_chat, "Voting Auto-Shotgun round!") } }
///////////////////////////////////////////////////////////// // Below is how to use cs_fw_war_start() forward. public cs_fw_war_start() { // Below is how to get current weapon war round. ;) // Just use native cs_current_war(const szWarName[], iLen); new sCurrentWar[32] cs_current_war(sCurrentWar, charsmax(sCurrentWar)) if(equal(sCurrentWar, "Auto-Shotgun")) { client_print(0, print_chat, "Now is Auto-Shotgun round!") } }
///////////////////////////////////////////////////////////// // Below is how to use cs_fw_vote_start() forward. public cs_fw_war_end() { client_print(0, print_chat, "End of war!") }
///////////////////////////////////////////////////////////// // Below is how to use cs_fw_vote_start() forward. public cs_fw_vote_start() { client_print(0, print_chat, "Please vote now!") }
///////////////////////////////////////////////////////////// // Below is how to use cs_fw_vote_end() forward. public cs_fw_vote_end() { client_print(0, print_chat, "End of voting!") }
///////////////////////////////////////////////////////////// // Below is how to use cs_is_point_leader(id) native. public fw_PlayerRespawn(id) { if(is_user_alive(id)) { // If point leader still in server after war round. Just tell about it again. ;) if(cs_is_point_leader(id)) { new szName[32] get_user_name(id, szName, charsmax(szName)) client_print(0, print_chat, "[WW] %s is points leader!", szName) } } }
API Example?
Just download the war_trail.sma file to see how to use them.
Then, open the war_trail.sma file to configure the trail color:
PHP Code:
g_iWarTrail = register_cvar("ww_allow_trail", "1") // Allow player trail during war round g_iCTAdminTrail = register_cvar("ww_CT_admin_trail", "0 255 0") // Trail color for CT admin g_iTAdminTrail = register_cvar("ww_T_admin_trail", "255 127 0") // Trail color for T admin g_iCTTrail = register_cvar("ww_CT_trail", "0 0 255") // Trail color for CT player g_iTTrail = register_cvar("ww_T_trail", "255 0 0") // Trail color for T player
Downloads:
Codes now is at GitHub:
Last edited by zmd94; 10-07-2015 at 00:33.
|
|