Code: Select all
/*
LOGS:
******************************************************************
********
1.3
********
- added cvar (active by default) for players' earning to be cut by half.
- check if player is connected when inviting (as it was giving errors)
* 1.3.1:
- bug fixes
* 1.3.2:
- bug fixes
- if player invites you, it doesnt open automatically menu unless you have update on
* 1.3.3:
- removed "bug report"
********
1.2
********
- improved updateammo
********
1.1.5
********
- nvault to save auto update
- fixed ammos increase for vips (before it would miss some, now it gets exactly half)
- reset join party requests
- fix when member join not showing in party
********
1.1
********
- if you refuse a team, it shows to people who sent you (unless they are in another team and not leaders)
- player can see your team members if you send him invite (through invite menu)
- party chat
- reason of party leaving
- notify leaving
- dont automatically show party menu if youre already in a team when you get invite
- fixed invites/kicks sometimes not working (it was using nicks to remove them, now it uses ids)
- fix possible g_p not resetting properly
- more understandable code for update ammo when cvar spec and cvar zombie are on/off
- request to join a party // remove update from menu and add /partyupdate
- switch leaders if leader wants // add in leader menu - "Change Leader"
- motd available commands
********
1.0b
********
- if player is spectator, doesnt earn ammos (to avoid people farming ammos by friends)
- added danish
********
1.0a
********
++++ funCheckInv - checks how many invites you have and returns number
++++ removeP - remove player from a team
++++ areYouSure(id) - menu
++++ invitesMenu
++++ yesNo for invites menu
++++ add player in a team
++++ updateAmmosAll every X seconds
++++ autoupdate(need 2 booleans array for menu open or not)
++++ invitare
++++ when zombie infects user
++++ edit g_p[4][32][4]
++++ FIX MENUS
++++ remove invites from players in your team
++++ calls update for every player // fix updateAll
++++ duct-tape: autoupdate // fix teamMenu showing over others
++++ MAX_PIT //define max people that can join in a team
++++ advertising
++++ fix updateammo
++++ fix team leaving
++++ fix ammos showing for wrong player g_p (wrong shift)
++++ add previous/next instead of just 6 in the invites
---- motd: try ugc motd with class/div
++++ if user zombie, no ammo
++++ add Leader Menu
++++ add menu for invite
++++ add menu for kick
++++ update on invite
++++ add notifications
++++ invite players who are already in another team
++++ add how many people are in the team on invites menu.
++++ motd/html
++++ if vips, remove 1 each update (since they earn 2x)
++++ fix sentences
***********
*/
#include <zombie_escape>
#include <cstrike>
#include <nvault>
#if AMXX_VERSION_NUM < 183
#define client_disconnected client_disconnect
#endif
#pragma compress 1
#define VERSION "1.3.3"
#define MAX_PLAYERSS 33
#define MAX_TEAMS 17
#define MAX_PIT 5 //min: 2, max: 6-10? - max teams possible
#define CHAT_TAG "[PARTY]" // or "[UGC.LT]"
//might make 500 if vip get every 500
#define DMG_TRIGGER 500 //how much dmg to do before updating ammos
#define TASK_UPDATEAMMO 190419
#define TASK_ADS 250419
#define MOTD_URL "http://info.ugc-gaming.net/motd/cs/partyinfo.html"
//reason to why getting kicked out of party
enum
{
SELF = 0,
KICKED,
LOW
}
//nvault
enum
{
VREAD = 0,
VWRITE
}
new bool:g_isInTeam[ MAX_PLAYERSS ]//if is in team or not
new g_teams[ MAX_TEAMS ][ MAX_PIT + 1 ]//max teams that can be created. max 4 players: saves #player - [numero team][posizione del giocatore]
new g_pTeams[ MAX_PLAYERSS ][ MAX_PIT + 1 ] //handles which #team and who in which position - [ id giocatore ][numero posizione nel team(1-leader, 2. co-leader etc)]
new bool:g_pInvites[ MAX_PLAYERSS ][ MAX_PLAYERSS ][ 2 ] //per ogni giocatore1 [primo], vedo se un altro giocatore2 gli ha fatto richiesta[secondo] e se g2 ha gia il team o lo vuole fare con te[terzo]
new g_invites[ MAX_PLAYERSS ] // tmp to keep id of who sends req
new g_p[ MAX_PIT ][ MAX_PLAYERSS ][ MAX_PIT ] // ammo update/saver - g_p[#giocatore nella squadra][id giocatore a cui mostrare][id giocatore che cambia ammo]
new g_pvec[ MAX_PLAYERSS ] //old ammo
//how much total earned for each player.
new g_total[ MAX_PLAYERSS ]
new Float:g_damage[ MAX_PLAYERSS ]
//[player][0] - updates menu. [player][1] = temp off so it doesnt override the other party menus
new bool:g_bIsAutoUpdate[ MAX_PLAYERSS ][ 2 ]
new bool:g_vipRemove[ MAX_PLAYERSS ], bool:g_playerRemove[ MAX_PLAYERSS ]
new cvar_zombie, cvar_vip, cvar_adstime, cvar_spec, cvar_pchat, cvar_half
//new g_joinPartyCallback
//handles requests made in team. - tmp to keep id of who sends req
new bool:g_joinRequests[ MAX_TEAMS ][ MAX_PLAYERSS ], g_recInvite[ MAX_PLAYERSS ]
new g_iVault // for nvault autoupdate
public plugin_init(){
register_plugin( "[ZP] Zombie Party", VERSION, "DusT" )
register_clcmd( "say /party", "teamMenu" )
register_clcmd( "party_menu", "teamMenu" )
register_clcmd( "zp_invite_user", "inviteP", _, "- Invite User in a Team" )
register_clcmd( "zp_remove_user", "kickP", _, "- Remove User from your Team (only Leader)")
register_clcmd( "say /partyinfo", "teamInfo", _, "Team Info")
register_clcmd( "amx_pchat", "partyChat", ADMIN_ALL, "< message >")
register_clcmd( "say", "sayPchat", ADMIN_ALL, "< message >")
register_clcmd( "say /partyupdate", "autoUpdateToggle")
register_clcmd( "say /partycmd", "cmdPartyMOTD")
register_clcmd( "say /partycmds", "cmdPartyMOTD")
register_concmd("zp_show_parties", "showParty", ADMIN_BAN)
register_cvar("Zombie_Party", VERSION, FCVAR_SERVER | FCVAR_SPONLY)
register_dictionary("zombieparty.txt")
cvar_zombie = register_cvar("zp_partyzombie_earn", "0") // should zombies earn ammos in team?
cvar_vip = register_cvar("zp_partyvip_decrease", "1") //should vip's ammo earn in team decrease (by half)
cvar_spec = register_cvar("zp_partyspec_earn", "0") // should spectators earn ammo in team?
cvar_adstime = register_cvar("zp_partyads_time", "250") //how often ads are updated
cvar_pchat = register_cvar("zp_party_chat", "2") //0 - off. 1 - normal admins can read. 2 - mods+. 3+ - only party members
cvar_half = register_cvar("zp_party_earn_half", "1") // earn half of what players earn instead of the whole ammo (otherwise it's too OP)
register_menu( "Are You Sure?", ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0 ), "menuYesNo" )
register_menu( "answerMenu", ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0 ), "answerMenuHandler" )
register_menu( "answerParty_Menu", ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0 ), "answerPartyMenuHandler" )
register_menu( "Team Menu", ( MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_0 ), "menuHandler" )
register_menu( "Leader Menu", ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_9 | MENU_KEY_0), "leaderMenuHandler")
//g_joinPartyCallback = menu_makecallback( "joinParty_callback" );
RegisterHam( Ham_Killed, "player", "fw_PlayerKilled_Post", 1 )
RegisterHam( Ham_TakeDamage, "player", "fw_TakeDamage", 0 )
g_iVault = nvault_open("ZombieParty")
set_task( 10.0, "updateAmmosAll2", TASK_UPDATEAMMO, _, _, "b" )
set_task( get_pcvar_float(cvar_adstime), "showAds", TASK_ADS, _, _, "b")
}
public ze_select_item_post(id, itemid){
updateAmmos( id )
return PLUGIN_HANDLED
}
public sayPchat( id ){
new message[128]
read_args(message, charsmax(message))
remove_quotes(message)
if(message[0] == '#'){
message[0] = ' '
trim(message)
client_cmd(id, "amx_pchat %s", message)
return PLUGIN_HANDLED_MAIN
}
return PLUGIN_CONTINUE
}
public partyChat( id, level, cid ){
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if(get_pcvar_num(cvar_pchat) == 0){
client_print(id, print_console, "Party Chat is OFF")
return PLUGIN_HANDLED
}
if(!g_isInTeam[id]){
client_print(id, print_console, "You need to be in a team to use Party Chat")
return PLUGIN_HANDLED
}
new message[192], players[32], num
read_args(message, charsmax(message))
remove_quotes(message)
format(message, charsmax(message), "!y[PARTYCHAT] !g%s : !y%s", GetUserNameReturned(id), message)
dust_print_color(id, "%s", message)
get_players(players, num)
for(new i = 0; i < num; i++){
if(get_pcvar_num(cvar_pchat) == 1){
if((get_user_flags(players[i]) & ADMIN_BAN) && g_pTeams[id][0] != g_pTeams[players[i]][0])
dust_print_color(players[i], "!g[PC%d] %s", g_pTeams[id] , message)
}
else if(get_pcvar_num(cvar_pchat) == 2){
if((get_user_flags(players[i]) & ADMIN_LEVEL_A) && g_pTeams[id][0] != g_pTeams[players[i]][0])
dust_print_color(players[i], "!g[PC%d] %s", g_pTeams[id] , message)
}
if(g_pTeams[id][0] == g_pTeams[players[i]][0] && players[i] != id)
dust_print_color(players[i], "%s", message)
}
return PLUGIN_HANDLED
}
public showParty( id, level, cid ){
if(!cmd_access(id, level, cid, 0))
return PLUGIN_HANDLED
if(!activeParty(0)){
client_print(id, print_console, "No active party.")
return PLUGIN_HANDLED
}
for(new i = 1; i < MAX_TEAMS; i++){
if(g_teams[i][0]){
client_print(id, print_console, "Party %d", i)
for(new j=1; j < MAX_PIT + 1; j++){
if(g_teams[i][j]>0)
client_print(id, print_console, " %d: %s", j, GetUserNameReturned(g_teams[i][j]))
}
}
}
return PLUGIN_HANDLED
}
public bool:activeParty( id ){
for(new i = 1; i < MAX_TEAMS; i++){
if(g_teams[i][0]){
if( !id )
return true
if(id && !g_joinRequests[i][id])
return true
}
}
return false
}
public getTeamPlayers( id ){
if(!g_isInTeam[ id ])
return 0
new num, counter = 0
for(new i = 1; i < MAX_PIT + 1; i++){
num = g_teams[ g_pTeams[id][0] ][ i ]
if(num > 0)
counter++
}
return counter
}
public showAds(){
dust_print_color(0, "!g[PARTY] !y%L !g/party !yor press !g'M'-'7' ", LANG_PLAYER, "PARTY_INFO")
dust_print_color(0, "!g[PARTY] !yMore info: say !g/partycmds !yor !g/partyinfo")
}
// !g - green , !y - default, !t - team color
stock dust_print_color(const id, const input[], any:...) {
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^x04"); // Green Color
replace_all(msg, 190, "!y", "^x01"); // Default Color
replace_all(msg, 190, "!t", "^x03"); // Team Color
if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
GetUserNameReturned( iPlayer ){
new szName[ 32 ];
get_user_name( iPlayer, szName, charsmax( szName ) );
return szName;
}
public updateAmmos( id ){
if( g_isInTeam[ id ] ){
new iPos, num, upd
//get id position in the team
for(new i = 1; i < MAX_PIT + 1; i++)
{
if(g_pTeams[ id ][ i ] == 1)
iPos = i - 1
}
//update difference = ammo - old ammo
upd = ze_get_escape_coins( id ) - g_pvec[ id ]
//old ammo
g_pvec[ id ] = ze_get_escape_coins( id )
// if update > 0, change g_vipremove and upd= upd - 1 if g_removeVip[id] or upd>=2
if(get_pcvar_num(cvar_vip)){
if(upd && upd%2){
g_vipRemove[ id ] = !g_vipRemove[ id ]
}
if((get_user_flags(id) & ADMIN_RESERVATION) && (g_vipRemove[ id ] || upd >=2) && upd>0){
upd--
}
}
if(get_pcvar_num(cvar_half)){
if(upd && upd%2)
g_playerRemove[ id ] = !g_playerRemove[ id ]
if((g_playerRemove[id] || upd >= 2) && upd > 0)
upd--
}
// if upd is not positive or 0
if( upd < 0 )
upd = 0
// if upd is > 20, block it - (max ammo upd should be 2-3) //moved to 20
if ( upd > 20){
upd = 0
//dust_print_color(id, "!g%s !yBUG!!! Report @ ugc-gaming.net!", CHAT_TAG)
}
for(new i = 0; i < MAX_PIT; i++){
num = g_teams[ g_pTeams[id][0] ][ i + 1 ]
if( num > 0){
// if zombies can earn ammos, add upd. if specs can earn ammos, add upd.
if( get_pcvar_num(cvar_zombie) || (!ze_is_user_zombie( id ) && !ze_is_user_zombie( num ))){
if(get_pcvar_num(cvar_spec) || (cs_get_user_team( id ) != CS_TEAM_SPECTATOR && cs_get_user_team( num ) != CS_TEAM_SPECTATOR)){
g_p[ i ][ num ][ iPos ] +=upd
g_total[ num ] += upd
}
}
if( num != id ){
g_pvec[ num ] = ze_get_escape_coins( num )
//if zombies can earn ammo, add ammos to team players. same for spec
if( get_pcvar_num(cvar_zombie) || (!ze_is_user_zombie( id ) && !ze_is_user_zombie( num )) ){
if(get_pcvar_num(cvar_spec) || ((is_user_connected(id) && is_user_connected(num)) && (cs_get_user_team( id ) != CS_TEAM_SPECTATOR && cs_get_user_team( num ) != CS_TEAM_SPECTATOR))){
ze_set_escape_coins( num, g_pvec[ num ] + upd)
g_pvec[ num ] = ze_get_escape_coins( num )
}
}
}
}
}
if(g_bIsAutoUpdate[ id ][0])
teamMenu( id )
}
}
//menu1
public areYouSure( id ){
//g_bIsAutoUpdate[id][0] = false
static szMenu[ 100 ]
new iKeys = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0;
new iLen = 0
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "\y%L?^n", id, "PARTY_SURE2")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\r1. \wYes")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\r2. \wNo")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n^n\r0. \wBack \d( No ) ")
show_menu( id, iKeys, szMenu, -1, "Are You Sure?" )
}
//menuhandler1
public menuYesNo( id, iKey ){
switch( ++iKey % 10 )
{
case 1:
{
removeP( id, SELF )
}
case 0:
{
teamMenu( id )
}
}
return PLUGIN_HANDLED
}
//menu3
public teamMenu( id ){
if(g_bIsAutoUpdate[id][1]){
g_bIsAutoUpdate[id][0] = true;
}
static szMenu[ 480 ]
new iLen = 0
iLen += formatex( szMenu, charsmax( szMenu ), "\r%L^n\w--------", id, "PARTY_TITLE" )
new iKeys = MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 | MENU_KEY_7;
new iPos
if(g_isInTeam[ id ]){
for(new i = 1; i < MAX_PIT + 1; i++)
{
if(g_pTeams[ id ][ i ] == 1)
iPos = i - 1;
}
for(new i = 0; i < MAX_PIT; i++){
if( g_teams[ g_pTeams[id][0] ][ i + 1 ] > 0 )
{
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\r- \w%s \y+%i AmmoPacks %s", GetUserNameReturned( g_teams[g_pTeams[id][0]][i+1] ), g_p[ iPos ][ id ][ i ], (i == 0)? "\w(\rLeader\w)":"" )
}
else{
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n")
}
}
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\wTotal: \y+%i AmmoPacks", g_total[ id ] )
}
new bool:inv = funCheckInv(id)? true:false
new bool:leader = (g_isInTeam[id] && g_pTeams[id][1] == 1) || !g_isInTeam[id]
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\w--------")
if(!get_pcvar_num(cvar_zombie) && ze_is_user_zombie( id )){
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\r%L", id, "PARTY_NOZOMBIE")
}
else if(!get_pcvar_num(cvar_spec) && cs_get_user_team( id ) == CS_TEAM_SPECTATOR){
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\rYou must not be spectator in order to get ammos")
}
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n^n%s4. Leader Menu", leader? "\r":"\d");
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n%s5. %s%L (%s%i%s)", (inv? "\r":"\d"), (inv? "\w":"\d"), id, "PARTY_INVITES" , (inv? "\r":"\d"), funCheckInv(id), (inv? "\w":"\d") )
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\%s6. %L", g_isInTeam[ id ]? "r":"d", id, "PARTY_LEAVE" );
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\%s7. \%sRequest to join Party", (activeParty(id) && !g_isInTeam[id])? "r":"d", (activeParty(id) && !g_isInTeam[id])? "w":"d" );
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n^n\r0. \wExit" )
show_menu( id, iKeys, szMenu, -1, "Team Menu" )
return PLUGIN_HANDLED
}
//menuhandler3
public menuHandler( id, iKey ){
g_bIsAutoUpdate[id][0] = false;
switch( ++iKey % 10 )
{
case 3:
{
engclient_cmd(id, "weapon_knife")
}
case 4:
{
if((g_isInTeam[id] && g_pTeams[id][1] == 1) || !g_isInTeam[id]){
leaderMenu(id)
}
else{
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOLEADER" )
teamMenu(id)
}
}
case 5:
{
if(funCheckInv(id)){
invitesMenu(id)
}
else{
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOINV" )
teamMenu( id )
}
}
case 6:
{
if(g_isInTeam[ id ]){
areYouSure( id )
}
else{
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOTIN" )
teamMenu( id )
}
}
case 7:
{
//free space - joinPartyRequest?
if(activeParty(id) && !g_isInTeam[id])
joinPartyMenu( id )
else if(!activeParty(id)) {
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_REQNOT")
teamMenu( id )
}
else{
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_IN")
teamMenu( id )
}
}
case 0:
{
//g_bIsAutoUpdate[ id ][0] = false;
}
}
return PLUGIN_HANDLED
}
public autoUpdateToggle( id ){
if(g_bIsAutoUpdate[ id ][ 1 ]){
g_bIsAutoUpdate[ id ][ 0 ] = false;
g_bIsAutoUpdate[ id ][ 1 ] = false;
dust_print_color( id, "!g%s !yAuto Update !gOFF", CHAT_TAG)
}
else{
g_bIsAutoUpdate[ id ][ 0 ] = true;
g_bIsAutoUpdate[ id ][ 1 ] = true;
dust_print_color( id, "!g%s !yAuto Update !gON", CHAT_TAG)
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_UPDATE" )
}
}
public teamInfo( id ){
show_motd(id, MOTD_URL, "Party Plugin Information")
}
public updateAmmosAll2(){
new players[ 32 ], num
get_players( players, num, "c")
for( new i = 0; i < num; i++ ){
updateAmmos( players[ i ] )
}
}
//menu2
public answerMenu( id, playerid ){
g_invites[ id ] = playerid
static szMenu[ 400 ]
new iKeys = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0;
new bool:team = g_isInTeam[ id ]
new iLen = 0
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "\y%L^n", id, "PARTY_JOIN")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "\yTeam Leader is \w%s^n", GetUserNameReturned( g_invites[ id ] ) )
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "\y%L", id, "PARTY_OTHERS" )
for(new i = 2; i < MAX_PIT + 1; i++){
if(getIdPos(playerid, i)>0){
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "\w%s %s", i!=2? ",":"", GetUserNameReturned(getIdPos(playerid, i)))
}
}
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n^n\%s1. \%sYes ", (team)? "d":"r", (team)? "d":"w")
if(team){
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "(%L)", id, "PARTY_IN")
}
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\r2. \wNo")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n^n\r0. \wBack \d( No ) ")
show_menu( id, iKeys, szMenu, -1, "answerMenu" )
}
//menuhandler2
public answerMenuHandler( id, iKey ){
switch( ++iKey % 10 )
{
case 1:
{
if(!g_isInTeam[ id ]){
joinTeam( id, g_invites[ id ], g_pInvites[ id ][ g_invites[id] ][ 1 ] )
g_pInvites[ id ][ g_invites[id] ][ 0 ] = false
g_pInvites[ id ][ g_invites[id] ][ 1 ] = false
g_invites[ id ] = 0;
}
else
{
dust_print_color( id, "!g%s !y%L %L", CHAT_TAG, id, "PARTY_IN", id, "PARTY_LEAVEMSG" )
answerMenu(id, g_invites[ id ])
}
}
case 2:
{
g_pInvites[ id ][ g_invites[id] ][ 0 ] = false
g_pInvites[ id ][ g_invites[id] ][ 1 ] = false
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_REFUSE", GetUserNameReturned(g_invites[ id ]))
if((g_isInTeam[g_invites[ id ]] && getIdPos(g_invites[ id ], 1) == g_invites[ id ]) || !g_isInTeam[g_invites[ id ]])
dust_print_color(g_invites[ id ], "!g%s !y%L", CHAT_TAG, g_invites[ id ], "PARTY_REFUSE2", GetUserNameReturned(id))
g_invites[ id ] = 0;
}
case 0:
{
invitesMenu( id )
}
}
return PLUGIN_HANDLED
}
//invite players menu
public sInvitesMenu( id ){
//g_bIsAutoUpdate[ id ][ 0 ] = false;
static menuid, buffer[2]
static szMenu[ 156 ]
formatex( szMenu, charsmax( szMenu ), "\r%L Menu^n", id, "PARTY_INVITES")
menuid = menu_create(szMenu, "sInvitesMenuHandler")
new p[ 32 ], num, counter = 0
get_players(p, num, "c")
for( new i = 0; i < num; i++ ){
if(!g_pInvites[ p[i] ][ id ][ 0 ] && id != p[i] && is_user_connected(p[i]) && (g_pTeams[id][0] != g_pTeams[p[i]][0] || g_pTeams[id][0]==0)){
formatex( szMenu, charsmax( szMenu ), "\w%s %s", GetUserNameReturned( p[i] ), g_isInTeam[p[i]]? "\r[IN ANOTHER PARTY]":"" )
buffer[0] = p[i]
buffer[1] = 0
menu_additem(menuid, szMenu, buffer)
counter++
}
}
if(counter == 0){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOTIN3")
teamMenu( id )
return PLUGIN_CONTINUE
}
formatex(szMenu, charsmax(szMenu), "Back")
menu_setprop(menuid, MPROP_BACKNAME, szMenu)
formatex(szMenu, charsmax(szMenu), "Next")
menu_setprop(menuid, MPROP_NEXTNAME, szMenu)
formatex(szMenu, charsmax(szMenu), "Exit")
menu_setprop(menuid, MPROP_EXITNAME, szMenu)
menu_display(id, menuid, 0)
return PLUGIN_HANDLED
}
public sInvitesMenuHandler( id, menuid, item){
if (!is_user_connected(id))
{
menu_destroy(menuid)
return PLUGIN_HANDLED;
}
if (item == MENU_EXIT)
{
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
static buffer[2], dummy, playerid
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
playerid = buffer[0]
inviteP(id, playerid)
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
//kick players menu
public sKickMenu( id ){
static menuid, buffer[2]
static szMenu[ 128 ]
formatex( szMenu, charsmax( szMenu ), "\r%L Menu^n", id, "PARTY_KICKMENU")
menuid = menu_create(szMenu, "sKickMenuHandler")
new num
for( new i = 1; i < MAX_PIT + 1; i++ ){
num = getIdPos(id, i)
if(num > 0){
formatex( szMenu, charsmax( szMenu ), "\w%s", GetUserNameReturned( num ) )
buffer[0] = num
buffer[1] = 0
menu_additem(menuid, szMenu, buffer)
}
}
formatex(szMenu, charsmax(szMenu), "Exit")
menu_setprop(menuid, MPROP_EXITNAME, szMenu)
menu_display(id, menuid, 0)
}
public sKickMenuHandler( id, menuid, item){
if (!is_user_connected(id))
{
menu_destroy(menuid)
return PLUGIN_HANDLED;
}
if (item == MENU_EXIT)
{
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
static buffer[2], dummy, playerid
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
playerid = buffer[0]
kickP(id, playerid)
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
public switchMenu( id ){
static menuid, buffer[2]
static szMenu[ 128 ]
formatex( szMenu, charsmax( szMenu ), "\r%L Menu^n", id, "PARTY_SWITCHMENU")
menuid = menu_create(szMenu, "switchMenuHandler")
new num
for( new i = 2; i < MAX_PIT + 1; i++ ){
num = getIdPos(id, i)
if(num > 0){
formatex( szMenu, charsmax( szMenu ), "\w%s", GetUserNameReturned( num ) )
buffer[0] = num
buffer[1] = 0
menu_additem(menuid, szMenu, buffer)
}
}
formatex(szMenu, charsmax(szMenu), "Exit")
menu_setprop(menuid, MPROP_EXITNAME, szMenu)
menu_display(id, menuid, 0)
}
public switchMenuHandler( id, menuid, item){
if (!is_user_connected(id))
{
menu_destroy(menuid)
return PLUGIN_HANDLED;
}
if (item == MENU_EXIT)
{
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
static buffer[2], dummy, playerid
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
playerid = buffer[0]
switchLeader(id, playerid)
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
public joinPartyMenu( id ){
static menuid, buffer[2]
static szMenu[ 128 ]
new bool:hasTeams = false
formatex( szMenu, charsmax( szMenu ), "\rJoin Party Menu^n")
menuid = menu_create(szMenu, "joinPartyMenuHandler")
for(new i = 1; i < MAX_TEAMS; i++){
if(g_teams[i][0] && !g_joinRequests[i][id]){
formatex( szMenu, charsmax(szMenu), "\yLeader: \w%s \%s [ %d ]", GetUserNameReturned(g_teams[i][1]), getIdPos(g_teams[i][1], MAX_PIT)? "r":"w", getTeamPlayers(g_teams[i][1]) )
buffer[0] = g_teams[i][1]
buffer[1] = 0
menu_additem(menuid, szMenu, buffer/*, _, g_joinPartyCallback*/ )
hasTeams = true
}
}
if(!hasTeams){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_REQNOT")
return PLUGIN_HANDLED
}
formatex(szMenu, charsmax(szMenu), "Back")
menu_setprop(menuid, MPROP_BACKNAME, szMenu)
formatex(szMenu, charsmax(szMenu), "Next")
menu_setprop(menuid, MPROP_NEXTNAME, szMenu)
formatex(szMenu, charsmax(szMenu), "Exit")
menu_setprop(menuid, MPROP_EXITNAME, szMenu)
menu_display(id, menuid, 0)
return PLUGIN_HANDLED
}
/*public joinParty_callback( id, menu, item){
static buffer[2], dummy, playerid
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
playerid = buffer[0]
if(getIdPos(playerid, MAX_PIT)){
return ITEM_DISABLED
}
return ITEM_IGNORE
}*/
public joinPartyMenuHandler( id, menuid, item){
if (!is_user_connected(id))
{
menu_destroy(menuid)
return PLUGIN_HANDLED;
}
if (item == MENU_EXIT)
{
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
static buffer[2], dummy, playerid
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
playerid = buffer[0]
joinPartyRequest(id, playerid)
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
//menu4
public invitesMenu( id ){
//g_bIsAutoUpdate[ id ][ 0 ] = false;
static menuid, buffer[2]
static menu[ 128 ]
formatex( menu, charsmax( menu ), "\r%L Menu^n", id, "PARTY_INVITES")
menuid = menu_create(menu, "invitesMenu2")
new bool:checker
new nums, ps[32]
get_players(ps, nums)
for( new i = 0; i < nums; i++ ){
if(g_pInvites[ id ][ ps[i] ][ 0 ]){
checker = (g_pTeams[ps[i]][1] || !g_isInTeam[ps[i]])
formatex( menu, charsmax( menu ), "\y%s\w%s \r[ %d ]", checker? "Leader: ":"", GetUserNameReturned( ps[i] ), getTeamPlayers( ps[i] ) )
buffer[0] = ps[i]
buffer[1] = 0
menu_additem(menuid, menu, buffer)
}
}
formatex(menu, charsmax(menu), "Back")
menu_setprop(menuid, MPROP_BACKNAME, menu)
formatex(menu, charsmax(menu), "Next")
menu_setprop(menuid, MPROP_NEXTNAME, menu)
formatex(menu, charsmax(menu), "Exit")
menu_setprop(menuid, MPROP_EXITNAME, menu)
menu_display(id, menuid, 0)
}
public invitesMenu2( id, menuid, item){
if( !is_user_connected( id) ){
menu_destroy(menuid)
return PLUGIN_HANDLED
}
if(item == MENU_EXIT){
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED
}
static buffer[2], dummy, playerid
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
playerid = buffer[0]
answerMenu( id, playerid)
menu_destroy(menuid)
return PLUGIN_HANDLED;
}
public funCheckInv( id ){
new counter = 0
for(new i = 0; i < MAX_PLAYERSS; i++ ){
if(g_pInvites[ id ][ i ][ 0 ])
counter++
}
return counter
}
public switchLeader(id, playerid){
if(!g_isInTeam[id] || !g_isInTeam[playerid] || g_pTeams[id][0] != g_pTeams[playerid][0] )
return PLUGIN_HANDLED
new playeridpos = 0
for(new i = 2; i < MAX_PIT + 1; i++){
if(getIdPos(id, i) == playerid){
playeridpos = i - 1
break
}
}
if(!playeridpos)
return PLUGIN_HANDLED
//switch g_teams
g_teams[g_pTeams[id][0]][playeridpos + 1] = id
g_teams[g_pTeams[id][0]][ 1 ] = playerid
//switch g_pTeams
g_pTeams[id][1] = 0
g_pTeams[id][playeridpos+1] = 1
g_pTeams[playerid][1] = 1
g_pTeams[playerid][playeridpos+1] = 0
//switch g_p
for(new i = 0; i < MAX_PIT; i++){
g_p[0][playerid][i] = g_p[playeridpos][playerid][i]
g_p[playeridpos][id][i] = g_p[0][id][i]
if(i == 0){
g_p[0][playerid][i] = g_p[playeridpos][playerid][playeridpos]
g_p[playeridpos][id][i] = g_p[0][id][playeridpos]
}
if(i==playeridpos){
g_p[0][playerid][i] = g_p[playeridpos][playerid][0]
g_p[playeridpos][id][i] = g_p[0][id][0]
}
}
//reset old g_p
for(new i = 0; i < MAX_PIT; i++){
g_p[0][id][i] = 0
g_p[playeridpos][playerid][i] = 0
}
for( new i = 1; i < MAX_PIT + 1; i++){
if(getIdPos(id,i)>0){
dust_print_color(getIdPos(id, i), "!g%s !y%L", CHAT_TAG, getIdPos(id, i), "PARTY_NEWLEADER2", GetUserNameReturned(playerid))
}
}
teamMenu( id )
if(g_bIsAutoUpdate[playerid][ 1 ])
teamMenu( playerid )
return PLUGIN_HANDLED
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
if(victim == attacker){
return HAM_IGNORED
}
if( !is_user_connected(attacker) ){
return HAM_IGNORED
}
if(ze_is_user_zombie(attacker)) {
return HAM_IGNORED
}
g_damage[attacker]+=damage
if(g_damage[attacker] > DMG_TRIGGER) {
if(g_isInTeam[ attacker ])
updateAmmos( attacker )
g_damage[attacker] -= DMG_TRIGGER
}
return HAM_HANDLED
}
public fw_PlayerKilled_Post(victim, attacker) {
if(victim == attacker){
return HAM_IGNORED
}
if(!is_user_connected(attacker)){
return HAM_IGNORED
}
updateAmmos( attacker )
return HAM_HANDLED
}
public ze_user_infected(id, infector){
if(id == infector){
return HAM_IGNORED
}
if(!is_user_connected(infector)){
return HAM_IGNORED
}
updateAmmos( infector )
return PLUGIN_HANDLED
}
public createTeam( id ){
if(g_isInTeam[ id ]){
dust_print_color( id, "!g%s !y%L %L", CHAT_TAG, id, "PARTY_IN", id, "PARTY_LEAVEMSG" )
return PLUGIN_HANDLED
}
for(new i = 1; i < MAX_TEAMS; i++ ){
if(!g_teams[ i ][ 0 ]){
g_teams[ i ][ 0 ] = 1;
g_isInTeam[ id ] = true;
g_teams[ i ][ 1 ] = id;
g_pTeams[ id ][ 0 ] = i;
g_pTeams[ id ][ 1 ] = 1;
break
}
}
for( new i = 0; i < MAX_PLAYERSS; i++ ){
if(g_pInvites[ i ][ id ][ 0 ]){
g_pInvites[ i ][ id ][ 1 ] = true
}
}
g_pvec[ id ] = ze_get_escape_coins( id )
return PLUGIN_HANDLED
}
public client_connect( id ){
g_pvec[ id ] = ze_get_escape_coins( id )
removeP( id, SELF)
for(new i = 0; i < MAX_PLAYERSS; i++ ){
g_pInvites[ id ][ i ][ 0 ] = false
g_pInvites[ id ][ i ][ 1 ] = false
g_pInvites[ i ][ id ][ 0 ] = false
g_pInvites[ i ][ id ][ 1 ] = false
}
g_invites[ id ] = 0
g_total[ id ] = 0
g_damage[ id ] = 0.0
saveUpdate(id, VREAD)
}
public saveUpdate( id, rw){
new name[32], data[2]
get_user_name(id, name, charsmax(name))
if(rw == VWRITE){
num_to_str(g_bIsAutoUpdate[id][1], data, charsmax(data))
nvault_set(g_iVault, name, data)
}
else{
nvault_get(g_iVault, name, data, charsmax(data))
g_bIsAutoUpdate[id][ 1 ] = str_to_num(data)? true : false
}
}
public joinTeam( id, leader, bool:hasTeam){
// id is already in a team
if(g_isInTeam[ id ]){
dust_print_color( id, "!g%s !y%L %L", CHAT_TAG, id, "PARTY_IN", id, "PARTY_LEAVEMSG" )
return PLUGIN_HANDLED
}
//"leader" is not actually leader (not anymore)
if(g_isInTeam[ leader ] && getIdPos( leader, 1 ) != leader ){
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_EXPIED" )
return PLUGIN_HANDLED
}
//if leader had team when sent request but doesn't have when i accept
if(hasTeam && !g_isInTeam[ leader ]){
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_EXPIED" )
return PLUGIN_HANDLED
}
//if leader has team
if(hasTeam){
if(getIdPos(leader, MAX_PIT) > 0 ){
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_FULL" )
return PLUGIN_HANDLED
}
for(new i = 2; i < MAX_PIT + 1; i++ ){
if(!getIdPos(leader, i)){
g_teams[ g_pTeams[ leader ][ 0 ] ][ i ] = id
g_pTeams[ id ][ i ] = 1
break
}
else{
dust_print_color(getIdPos(leader,i), "!g%s !y'%s' %L", CHAT_TAG, GetUserNameReturned(id), getIdPos(leader,i), "PARTY_JOINED" )
}
}
}
else{
createTeam( leader )
g_teams[ g_pTeams[leader][0] ][ 2 ] = id
g_pTeams[ id ][ 2 ] = 1
}
g_pTeams[ id ][ 0 ] = g_pTeams[ leader ][ 0 ]
g_isInTeam[ id ] = true;
g_pvec[ id ] = ze_get_escape_coins( id )
//reset invites for players in same team
new num
for(new i = 1; i < MAX_PIT + 1; i++){
num = getIdPos(id, i)
if(num > 0){
g_pInvites[ num ][ id ][ 0 ] = false;
g_pInvites[ num ][ id ][ 1 ] = false;
g_pInvites[ id ][ num ][ 0 ] = false;
g_pInvites[ id ][ num ][ 1 ] = false;
}
}
for(new i = 1; i < MAX_PIT; i++){
if(getIdPos(leader,i) && g_bIsAutoUpdate[getIdPos(leader,i)][ 1 ])
teamMenu(getIdPos(leader,i))
}
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_JOINED2", GetUserNameReturned( leader ) )
dust_print_color( leader, "!g%s !y'%s' %L", CHAT_TAG, GetUserNameReturned( id ), leader, "PARTY_JOINED" )
return PLUGIN_HANDLED
}
public inviteP( id, playerid ){
new player
if(!playerid){
new arg [ 33 ];
read_argv ( 1, arg, charsmax ( arg ) );
player = cmd_target ( id, arg, CMDTARGET_NO_BOTS );
}
else{
player = playerid
}
if(!is_user_connected(player)){
dust_print_color(id, "!g%s !yPlayer is not connected.", CHAT_TAG)
return PLUGIN_HANDLED
}
//if player is id
if(id == player){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_YOURSELF")
return PLUGIN_HANDLED
}
//already sent request
if(g_pInvites[ player ][ id ][ 0 ]){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_SENT2", GetUserNameReturned( player ) )
return PLUGIN_HANDLED
}
//if player is server (doesn't exist)
if(!player)
return PLUGIN_HANDLED
//if player is already in your team
for(new i = 1; i < MAX_PIT + 1; i++){
if(g_teams[ g_pTeams[id][0]][i] == player){
dust_print_color(id, "!g%s !y'%s' %L", CHAT_TAG, GetUserNameReturned( player ), id, "PARTY_IN2" )
return PLUGIN_HANDLED
}
}
//if id is in a team but not leader
if(g_isInTeam[id] && !g_pTeams[id][1] ){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_INVLEADER")
return PLUGIN_HANDLED
}
g_pInvites[ player ][ id ][ 0 ] = true;
if(g_isInTeam[ id ]){
g_pInvites[ player ][ id ][ 1 ] = true;
}
dust_print_color(id, "!g%s !y%L '%s'", CHAT_TAG, id, "PARTY_SENT", GetUserNameReturned( player ) )
dust_print_color(player, "!g%s !y%L", CHAT_TAG, player, "PARTY_REC", GetUserNameReturned(id))
if(!g_isInTeam[player] && g_bIsAutoUpdate[id][0])
teamMenu( player )
return PLUGIN_HANDLED
}
public kickP( id, playerid ){
new player
if(!playerid){
new arg [ 33 ];
read_argv ( 1, arg, charsmax ( arg ) );
player = cmd_target ( id, arg, CMDTARGET_NO_BOTS );
if(player == 0 || !g_isInTeam[ player ])
return PLUGIN_HANDLED
}
else{
player = playerid
}
if( g_pTeams[id][0] != g_pTeams[player][0] ){
dust_print_color(id, "!g%s !y%s %L", CHAT_TAG, GetUserNameReturned(player), id, "PARTY_NOTIN2")
return PLUGIN_HANDLED
}
if( getIdPos( id , 1 ) == id ){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_REMOVED", GetUserNameReturned( player ) )
removeP( player, KICKED )
if(g_bIsAutoUpdate[ id ][0])
teamMenu( id )
}
return PLUGIN_HANDLED
}
public removeP( id, reason ){
if( !g_isInTeam[ id ] ){
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOTIN" )
return PLUGIN_HANDLED
}
new iPos, num, num2, notify_team, bool:wasLeader = false, bool:closed = false
notify_team = g_pTeams[ id ][ 0 ]
//save id's position in the team
for(new j = 1; j < MAX_PIT + 1; j++)
{
if(g_pTeams[ id ][ j ] == 1)
iPos = j - 1
}
//if id is leader delete invites where it was showing that leader had team
if( iPos == 0 ){
for(new i = 0; i < MAX_PLAYERSS; i++ ){
if(g_pInvites[ i ][ id ][ 0 ]){
g_pInvites[ i ][ id ][ 1 ] = false;
}
wasLeader = true;
}
}
//shift player ammos showing and teams name saver (g_p g_teams)
for(new i = 0; i < MAX_PIT - 1; i++ ){
num = g_teams[ g_pTeams[id][0] ][ i + 1 ]
num2 = g_teams[ g_pTeams[id][0] ][ i + 2 ]
for(new j = 0; j < MAX_PIT - 1; j++ ){
if(i < iPos && j >= iPos){
g_p[ i ][ num ][ j ] = g_p[ i ][ num ][ j + 1 ]
}
if( i >= iPos ){
g_p[ i ][ num2 ][ j ] = g_p[ i + 1 ][ num2 ][ j + 1]
if( j == MAX_PIT - 2 ){
g_p[ i ][ num2 ][ j + 1 ] = 0
}
}
if( i == MAX_PIT - 2 ){
g_p[ i + 1 ][ num2 ][ j ] = 0
if( j == MAX_PIT - 2 )
g_p[ i + 1 ][ num2 ][ j + 1 ] = 0
}
if( j == MAX_PIT - 2 ){
g_p[ i ][ num ][ j + 1 ] = 0
}
}
if(i >= iPos){
g_teams[ g_pTeams[id][0] ][ i + 1 ] = num2
}
if(i == MAX_PIT - 2){
g_teams[ g_pTeams[id][0] ][ i + 2 ] = 0
}
}
// extra safety - reset g_p player who left
for( new i = 0; i < MAX_PIT; i++ )
g_p[ iPos ][ id ][ i ] = 0
new count = 0
for( new s = 1; s < MAX_PIT + 1; s++ ){
if(getIdPos(id, s) > 0)
count++;
}
g_teams[ notify_team ][ MAX_PIT ] = 0; //last player will surely be 0
g_total[ id ] = 0
g_isInTeam[ id ] = false
//shift g_pTeams
for(new i = 1; i < MAX_PIT + 1; i++){
num = g_teams[notify_team][i]
if(num > 0){
for(new j = 1; j < MAX_PIT + 1; j++ )
g_pTeams[ num ][ j ] = 0
g_pTeams[ num ][ i ] = 1
}
}
//notify (ex)party members that you left
for(new i = 1; i < MAX_PIT + 1; i++){
if(g_teams[notify_team][i]>0){
dust_print_color(g_teams[notify_team][i], "!g%s !y%L", CHAT_TAG, g_teams[notify_team][i], "PARTY_LEFT2", GetUserNameReturned(id))
if(wasLeader && !closed)
dust_print_color(g_teams[notify_team][i], "!g%s !y%L %L", CHAT_TAG, g_teams[notify_team][i], "PARTY_NEWLEADER", g_teams[notify_team][i], "PARTY_NEWLEADER2", GetUserNameReturned(g_teams[notify_team][1]))
}
}
if(reason == LOW){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_CLOSED")
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_LEFT" )
}
else if(reason == KICKED){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_KICKED")
}
else{
dust_print_color( id, "!g%s !y%L", CHAT_TAG, id, "PARTY_LEFT" )
}
// if there is only 1 player left in the party, close the party
if(count <= 1){
if(getIdPos(id, 1) > 0 && getIdPos(id, 1) != id ){
removeP(getIdPos(id, 1), LOW)
}
else if(getIdPos(id, 2) > 0 && getIdPos(id, 2) != id ){
removeP(getIdPos(id, 2), LOW)
}
g_teams[ g_pTeams[id][0] ][ 0 ] = 0
closed = true
//reset join requests
for( new i = 0; i < MAX_PLAYERSS; i++){
g_joinRequests[notify_team][ i ] = false
}
}
//reset g_pTeams[id]
for(new i = 0; i < MAX_PIT + 1; i++)
g_pTeams[ id ][ i ] = 0;
teamMenu( id )
for(new i = 1; i < MAX_PIT + 1; i++){
num = g_teams[ notify_team ][ i ]
if(num > 0 && g_bIsAutoUpdate[num][ 1 ])
teamMenu( num )
}
return PLUGIN_HANDLED
}
//ritorna ID giocatore in posizione pos nello stesso team di "id"
public getIdPos( id6, pos ){
return g_teams[ g_pTeams[ id6 ][ 0 ] ][ pos ]
}
//leader menu
public leaderMenu( id ){
//g_bIsAutoUpdate[id][0] = false
static szMenu[ 300 ]
new iKeys = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_9 | MENU_KEY_0;
new iLen = 0
new bool:check = (g_teams[ g_pTeams[id][0] ][ MAX_PIT ] > 0)
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "\rLeader Menu^n")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "^n\%s1. \%s%L", check? "d":"r", check? "d":"w", id, "PARTY_INVMENU")
check = !g_isInTeam[ id ]
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "^n\%s2. \%s%L", check? "d":"r", check? "d":"w", id, "PARTY_KICKMENU")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "^n\%s3. \%s%L", check? "d":"r", check? "d":"w", id, "PARTY_SWITCHMENU")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "^n\%s4. \%sParty Requests Menu", check? "d":"r", check? "d":"w")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "^n^n^n\r9. \wBack")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "^n^n\r0. \wExit")
show_menu( id, iKeys, szMenu, -1, "Leader Menu" )
}
//leaderMenuhandler
public leaderMenuHandler( id, iKey ){
switch( ++iKey % 10 )
{
case 1:
{
if((g_teams[ g_pTeams[id][0] ][ MAX_PIT ] > 0)){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_FULL")
leaderMenu( id )
}
else{
sInvitesMenu( id )
}
}
case 2:
{
if(!g_isInTeam[id]){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOKICK")
leaderMenu( id )
}
else{
sKickMenu( id )
}
}
case 3:
{
if(!g_isInTeam[id]){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOTIN")
leaderMenu( id )
}
else{
switchMenu( id )
}
}
case 4:
{
if(!g_isInTeam[id]){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOTIN")
leaderMenu( id )
}
else{
partyRecMenu( id )
}
}
case 9:
{
teamMenu( id )
}
case 0:
{
//exit
}
}
return PLUGIN_HANDLED
}
public joinPartyRequest( id, playerid ){
if(g_isInTeam[id]){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_IN")
teamMenu( id )
return PLUGIN_HANDLED
}
if(getIdPos(playerid, 1) != playerid){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_REQNOT2")
teamMenu( id )
return PLUGIN_HANDLED
}
new team = g_pTeams[playerid][0]
g_joinRequests[ team ][ id ] = true
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_REQASK", GetUserNameReturned(playerid))
dust_print_color(playerid, "!g%s !y%L", CHAT_TAG, playerid, "PARTY_REQASK2", GetUserNameReturned(id))
return PLUGIN_HANDLED
}
public partyRecMenu( id ){
static menuid, buffer[2]
static szMenu[ 128 ]
formatex( szMenu, charsmax( szMenu ), "\rParty Requests Menu^n")
menuid = menu_create(szMenu, "partyRecMenuHandler")
new ps[32], num, bool:hasPlayers = false
get_players(ps, num, "c")
for(new i = 0; i < num; i++){
if(g_joinRequests[g_pTeams[id][0]][ ps[i] ]){
hasPlayers = true
formatex( szMenu, charsmax(szMenu), "\y%s", GetUserNameReturned(ps[i]))
buffer[0] = ps[i]
buffer[1] = 0
menu_additem(menuid, szMenu, buffer/*, _, g_joinPartyCallback*/ )
}
}
if(!hasPlayers){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_NOREQ" )
leaderMenu( id )
return PLUGIN_HANDLED
}
formatex(szMenu, charsmax(szMenu), "Back")
menu_setprop(menuid, MPROP_BACKNAME, szMenu)
formatex(szMenu, charsmax(szMenu), "Next")
menu_setprop(menuid, MPROP_NEXTNAME, szMenu)
formatex(szMenu, charsmax(szMenu), "Exit")
menu_setprop(menuid, MPROP_EXITNAME, szMenu)
menu_display(id, menuid, 0)
return PLUGIN_HANDLED
}
public partyRecMenuHandler( id, menuid, item ){
if (!is_user_connected(id))
{
menu_destroy(menuid)
return PLUGIN_HANDLED;
}
if (item == MENU_EXIT)
{
menu_destroy(menuid)
teamMenu( id )
return PLUGIN_HANDLED;
}
static buffer[2], dummy, playerid
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
playerid = buffer[0]
//answerPartyMenu(playerid, id)
answerPartyMenu(id, playerid)
menu_destroy(menuid)
return PLUGIN_HANDLED;
}
//joinparty answer handler.
public answerPartyMenu( id, playerid ){
g_recInvite[ id ] = playerid
static szMenu[ 400 ]
new iKeys = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0;
new bool:team
team = (getIdPos(id, MAX_PIT)>0)
new iLen = 0
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "\wAccept '\y%s\w'?^n", GetUserNameReturned(playerid))
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "\y%L?^n", id, "PARTY_SURE")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n^n\%s1. \%sYes ", (team)? "d":"r", (team)? "d":"w")
if(team){
iLen += formatex( szMenu[ iLen ], charsmax( szMenu), "(Party FULL)")
}
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n\r2. \wNo")
iLen += formatex( szMenu[ iLen ], charsmax( szMenu ), "^n^n\r0. \wBack \d( No ) ")
show_menu( id, iKeys, szMenu, -1, "answerParty_Menu" )
}
public answerPartyMenuHandler( id, iKey ){
switch( ++iKey % 10 )
{
case 1:
{
if(!getIdPos(id, MAX_PIT) && !g_isInTeam[ g_recInvite[id] ]){
joinTeam(g_recInvite[ id ], id, true)
g_joinRequests[ g_pTeams[id][0]][g_recInvite[id]] = false
}
else if(getIdPos(id, MAX_PIT)){
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_FULL")
}
else{
dust_print_color(id, "!g%s !y%L", CHAT_TAG, id, "PARTY_EXPIED")
g_joinRequests[ g_pTeams[id][0]][g_recInvite[id]] = false
}
}
case 2:
{
g_joinRequests[ g_pTeams[id][0]][g_recInvite[id]] = false
}
case 0:
{
//exit
}
}
teamMenu( id )
g_recInvite[ id ] = 0
return PLUGIN_HANDLED
}
public cmdPartyMOTD( id ){
new len = 0, message[ 1500 ]
len +=formatex(message[len], charsmax(message), "<meta charset=UTF-8><body><h1 style='text-align: center;'>Zombie Party Plugin</h1>")
len +=formatex(message[len], charsmax(message), "<h3 style='text-align: center;'>Current Version: %s</h3><h4 style='text-align: center;'>Author: DusT</h4>", VERSION)
len +=formatex(message[len], charsmax(message), "<h3>Available Commands</h3><br>")
len +=formatex(message[len], charsmax(message), "<p><b>say /party</b> - Opens party menu</p>")
len +=formatex(message[len], charsmax(message), "<p><b>party_menu</b> - Opens party menu</p>")
len +=formatex(message[len], charsmax(message), "<p><b>say /partyupdate</b> - Toggle Auto Update</p>")
len +=formatex(message[len], charsmax(message), "<p><b>say /partycmd</b> - Opens this motd</p>")
len +=formatex(message[len], charsmax(message), "<p><b>say #< message ></b> - Writes message to party members</p>")
len +=formatex(message[len], charsmax(message), "<p><b>amx_pchat < message ></b> - Writes message to party members</p>")
len +=formatex(message[len], charsmax(message), "<p><b>zp_invite_user < nick ></b> - Invites user to your party</p>")
len +=formatex(message[len], charsmax(message), "<p><b>zp_remove_user < nick ></b> - Kicks user from your party</p>")
len +=formatex(message[len], charsmax(message), "<p><b>[ADMINS]zp_show_parties</b> - Shows active parties and their members</p><br><br>")
len +=formatex(message[len], charsmax(message), "<p><b>say /partyinfo</b> - Further info about Zombie Party</p>")
show_motd(id, message, "Available Party Commands")
}
L 09/02/2019 - 21:07:25: [AMXX] Displaying debug trace (plugin "zombieparty.amxx", version "1.3.3")
L 09/02/2019 - 21:07:25: [AMXX] Run time error 10: native error (native "ze_get_escape_coins")
L 09/02/2019 - 21:07:25: [AMXX] [0] zombieparty.sma::client_connect (line 1032)