Senior Member
Join Date: Dec 2014
Location: Iraq
|
12-09-2015
, 10:30
[Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
|
#1
|
Third Lesson Add (Leader)
- all rights reserved to arvEL.-, in : 9/12/2015 In these lesson i will explain how to develop [Zombie Plague Advance v1.6.1]
add leader frags + packs when start any round.
first go to this topic [ # ] and download[ZPA 1.6.1]
after that open the file [zombie_plague_advance_v1-6-1.sma] in [notepad++]
first add this library
PHP Code:
#include <Commas>
after that add this native
PHP Code:
native zp_get_user_ammo_packs(id);
after that. add this codes in any place in ZPA.sma main.
PHP Code:
public Leader() { new iAmmoPacks new iLeader = GetLeader_Ammo(iAmmoPacks) new szName[32] get_user_name( iLeader, szName, 31 ) static PacksString[16]; AddCommas(g_ammopacks[iLeader], PacksString, 15); client_print_color( 0, Grey, "^x04[ZP]^x01 The packs leader is ^3%s ^1@ ^4%s packs", szName, PacksString) set_task(0.1, "Leader_Frags") }
public Leader_Frags() { new iFrags new iLeader = GetLeader_Frags(iFrags) new szName[32] get_user_name( iLeader, szName, 31 ) client_print_color( 0, Grey, "^x04[ZP]^x01 The frags leader is ^3%s ^1@ ^4%d frags", szName, iFrags) }
GetLeader_Ammo( &iAmmoPacks ) { new iPlayers[32], iNum, id, i, iLeader, iPacks get_players( iPlayers, iNum, "ch" ) for ( i = 0; i < iNum; i++ ) { id = iPlayers[i] iPacks = zp_get_user_ammo_packs(id) if ( iPacks > iAmmoPacks ) { iAmmoPacks = iPacks iLeader = id } } return iLeader; }
GetLeader_Frags( &iFrags ) { new iPlayers[32], iNum, id, i, iLeader, iFrag get_players( iPlayers, iNum, "ch" ) for ( i = 0; i < iNum; i++ ) { id = iPlayers[i] iFrag = get_user_frags(id) if ( iFrag > iFrags ) { iFrags = iFrag iLeader = id } } return iLeader; }
after that. press [Ctrl + F] and write.
PHP Code:
// Log Event Round End
it's have this codes:
PHP Code:
// Log Event Round End public logevent_round_end() { // Prevent this from getting called twice when restarting (bugfix) static Float:lastendtime, Float:current_time current_time = get_gametime() if (current_time - lastendtime < 0.5) return; lastendtime = current_time // Temporarily save player stats? if (get_pcvar_num(cvar_statssave)) { static id, team for (id = 1; id <= g_maxplayers; id++) { // Not connected if (!g_isconnected[id]) continue; team = fm_cs_get_user_team(id) // Not playing if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED) continue; save_stats(id) } } // Round ended g_endround = true // No infection allowed g_allowinfection = false // No current mode is bieng played g_currentmode = MODE_NONE // Stop old tasks (if any) remove_task(TASK_WELCOMEMSG) remove_task(TASK_MAKEZOMBIE) // Stop ambience sounds if ((g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && g_nemround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && g_survround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && g_swarmround) || (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && g_plagueround) || (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_survround && !g_swarmround && !g_plagueround && !g_sniperround && !g_assassinround && !g_lnjround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && g_sniperround) || (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && g_assassinround) || (g_ambience_sounds[AMBIENCE_SOUNDS_LNJ] && g_lnjround)) { remove_task(TASK_AMBIENCESOUNDS) ambience_sound_stop() } // Show HUD notice, play win sound, update team scores... static sound[64] if (!fnGetZombies()) { // Human team wins set_hudmessage(0, 0, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN") // Play win sound and increase score ArrayGetString(sound_win_humans, random_num(0, ArraySize(sound_win_humans) - 1), sound, charsmax(sound)) PlaySound(sound) g_scorehumans++ // Round end forward ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_HUMAN); } else if (!fnGetHumans()) { // Zombie team wins set_hudmessage(200, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_ZOMBIE") // Play win sound and increase score ArrayGetString(sound_win_zombies, random_num(0, ArraySize(sound_win_zombies) - 1), sound, charsmax(sound)) PlaySound(sound) g_scorezombies++ // Round end forward ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_ZOMBIE); } else if (get_pcvar_num(cvar_humansurvive)) { // Humans survived the plague set_hudmessage(0, 200, 100, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN_SURVIVE") // Play win sound and increase human score ArrayGetString(sound_win_humans, random_num(0, ArraySize(sound_win_humans) - 1), sound, charsmax(sound)) PlaySound(sound) g_scorehumans++ // Round end forward (will remain same) ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_NO_ONE); } else { // No one wins set_hudmessage(0, 200, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_NO_ONE") // Play win sound and increase human score ArrayGetString(sound_win_no_one, random_num(0, ArraySize(sound_win_no_one) - 1), sound, charsmax(sound)) PlaySound(sound) // Round end forward ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_NO_ONE); } // Balance the teams balance_teams() }
replace all codes to:
PHP Code:
// Log Event Round End public logevent_round_end() { set_task(1.0, "Leader") // Prevent this from getting called twice when restarting (bugfix) static Float:lastendtime, Float:current_time current_time = get_gametime() if (current_time - lastendtime < 0.5) return; lastendtime = current_time // Temporarily save player stats? if (get_pcvar_num(cvar_statssave)) { static id, team for (id = 1; id <= g_maxplayers; id++) { // Not connected if (!g_isconnected[id]) continue; team = fm_cs_get_user_team(id) // Not playing if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED) continue; save_stats(id) } } // Round ended g_endround = true // No infection allowed g_allowinfection = false // No current mode is bieng played g_currentmode = MODE_NONE // Stop old tasks (if any) remove_task(TASK_WELCOMEMSG) remove_task(TASK_MAKEZOMBIE) // Stop ambience sounds if ((g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && g_nemround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && g_survround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && g_swarmround) || (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && g_plagueround) || (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_survround && !g_swarmround && !g_plagueround && !g_sniperround && !g_assassinround && !g_lnjround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && g_sniperround) || (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && g_assassinround) || (g_ambience_sounds[AMBIENCE_SOUNDS_LNJ] && g_lnjround)) { remove_task(TASK_AMBIENCESOUNDS) ambience_sound_stop() } // Show HUD notice, play win sound, update team scores... static sound[64] if (!fnGetZombies()) { // Human team wins set_hudmessage(0, 0, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN") // Play win sound and increase score ArrayGetString(sound_win_humans, random_num(0, ArraySize(sound_win_humans) - 1), sound, charsmax(sound)) PlaySound(sound) g_scorehumans++ // Round end forward ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_HUMAN); } else if (!fnGetHumans()) { // Zombie team wins set_hudmessage(200, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_ZOMBIE") // Play win sound and increase score ArrayGetString(sound_win_zombies, random_num(0, ArraySize(sound_win_zombies) - 1), sound, charsmax(sound)) PlaySound(sound) g_scorezombies++ // Round end forward ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_ZOMBIE); } else if (get_pcvar_num(cvar_humansurvive)) { // Humans survived the plague set_hudmessage(0, 200, 100, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN_SURVIVE") // Play win sound and increase human score ArrayGetString(sound_win_humans, random_num(0, ArraySize(sound_win_humans) - 1), sound, charsmax(sound)) PlaySound(sound) g_scorehumans++ // Round end forward (will remain same) ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_NO_ONE); } else { // No one wins set_hudmessage(0, 200, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1) ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_NO_ONE") // Play win sound and increase human score ArrayGetString(sound_win_no_one, random_num(0, ArraySize(sound_win_no_one) - 1), sound, charsmax(sound)) PlaySound(sound) // Round end forward ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_NO_ONE); } // Balance the teams balance_teams() }
now make compile and ejnoy
all rights reserved to arvEL.-
__________________
Last edited by arvEL.; 10-07-2016 at 11:24.
|
|