[API] Weapons War v6.3
(26 Weapons + 4 Forwards)
Status:
UP-TO-DATE (1/2/2015)
Changelog:
Quote:
(1/2/2015)
v6.3
- [FIXED] Improved the code.
- [ADDED] New natives to allow player to design their own weapon war. ;)
- [ADDED] New options to allow auto-respawn. ;)
|
Advantages?
This plugin is different from other weapons round plugin:
1. Now, you can start custom war round. Just download custom_war.sma to see how I'm using the new natives. ;)
New senteces?
So, I would love if anyone can help me to translate the word into their language. Just visit here to help me to translate it:
https://forums.alliedmods.net/showthread.php?t=246330
Code:
[en]
WAR = %s round!
WAR2 = Current round: ^n%s war!
New natives?
So, this is the list of natives and forwards:
PHP Code:
/*
* 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 point leader
* param id - ID of client
*/
native cs_is_point_leader(id);
Custom Weapon War?
Just see
custom_war.sma file. ;)
PHP Code:
#include <amxmodx>
#include <fakemeta>
#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 /cw", "clcmd_custom_war")
register_clcmd("say_team /cw", "clcmd_custom_war")
register_clcmd("say /cvote", "clcmd_custom_vote")
register_clcmd("say_team /ccvote", "clcmd_custom_vote")
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))
// No.'11' is number of characters to compare.
// In this example is '11' characters. ;)
if(equal(g_sCurrentWar, "Head Hunter", 11))
{
client_print(0, print_chat, "[WW] Run everyone!")
}
}
// 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
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", 11))
{
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", 11))
{
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)
}
}
}