Raised This Month: $51 Target: $400
 12% 

[Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 12-09-2015 , 10:30   [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #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_nameiLeaderszName31 )         
    static 
PacksString[16];
    
AddCommas(g_ammopacks[iLeader], PacksString15);
    
client_print_color0Grey"^x04[ZP]^x01 The packs leader is ^3%s ^1@ ^4%s packs"szNamePacksString)
    
set_task(0.1"Leader_Frags")
}

public 
Leader_Frags()
{
    new 
iFrags
    
new iLeader GetLeader_Frags(iFrags)        
    new 
szName[32]
    
get_user_nameiLeaderszName31 )                 
    
client_print_color0Grey"^x04[ZP]^x01 The frags leader is ^3%s ^1@ ^4%d frags"szNameiFrags
}

GetLeader_Ammo( &iAmmoPacks )
{
    new 
iPlayers[32], iNumidiiLeaderiPacks
    get_players
iPlayersiNum"ch" )
    for ( 
0iNumi++ )
    {
    
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], iNumidiiLeaderiFrag
    get_players
iPlayersiNum"ch" )
    for ( 
0iNumi++ )
    {
    
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:lastendtimeFloat: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 
idteam
        
for (id 1id <= g_maxplayersid++)
        {
            
// 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(00200HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_HUMAN")
        
        
// Play win sound and increase score
        
ArrayGetString(sound_win_humansrandom_num(0ArraySize(sound_win_humans) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
g_scorehumans++
        
        
// Round end forward
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_TEAM_HUMAN);
    }
    else if (!
fnGetHumans())
    {
        
// Zombie team wins
        
set_hudmessage(20000HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_ZOMBIE")
        
        
// Play win sound and increase score
        
ArrayGetString(sound_win_zombiesrandom_num(0ArraySize(sound_win_zombies) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
g_scorezombies++
        
        
// Round end forward
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_TEAM_ZOMBIE);
    }
    else if (
get_pcvar_num(cvar_humansurvive))
    {
        
// Humans survived the plague
        
set_hudmessage(0200100HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_HUMAN_SURVIVE")
        
        
// Play win sound and increase human score
        
ArrayGetString(sound_win_humansrandom_num(0ArraySize(sound_win_humans) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
g_scorehumans++
        
        
// Round end forward (will remain same)
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_TEAM_NO_ONE);
    }
    else 
    {
        
// No one wins
        
set_hudmessage(02000HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_NO_ONE")
        
        
// Play win sound and increase human score
        
ArrayGetString(sound_win_no_onerandom_num(0ArraySize(sound_win_no_one) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
        
// Round end forward
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_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:lastendtimeFloat: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 
idteam
        
for (id 1id <= g_maxplayersid++)
        {
            
// 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(00200HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_HUMAN")
        
        
// Play win sound and increase score
        
ArrayGetString(sound_win_humansrandom_num(0ArraySize(sound_win_humans) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
g_scorehumans++
        
        
// Round end forward
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_TEAM_HUMAN);
    }
    else if (!
fnGetHumans())
    {
        
// Zombie team wins
        
set_hudmessage(20000HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_ZOMBIE")
        
        
// Play win sound and increase score
        
ArrayGetString(sound_win_zombiesrandom_num(0ArraySize(sound_win_zombies) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
g_scorezombies++
        
        
// Round end forward
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_TEAM_ZOMBIE);
    }
    else if (
get_pcvar_num(cvar_humansurvive))
    {
        
// Humans survived the plague
        
set_hudmessage(0200100HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_HUMAN_SURVIVE")
        
        
// Play win sound and increase human score
        
ArrayGetString(sound_win_humansrandom_num(0ArraySize(sound_win_humans) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
g_scorehumans++
        
        
// Round end forward (will remain same)
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_TEAM_NO_ONE);
    }
    else 
    {
        
// No one wins
        
set_hudmessage(02000HUD_EVENT_XHUD_EVENT_Y00.03.02.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"WIN_NO_ONE")
        
        
// Play win sound and increase human score
        
ArrayGetString(sound_win_no_onerandom_num(0ArraySize(sound_win_no_one) - 1), soundcharsmax(sound))
        
PlaySound(sound)
        
        
// Round end forward
        
ExecuteForward(g_fwRoundEndg_fwDummyResultZP_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.
arvEL. is offline
Send a message via Skype™ to arvEL.
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-09-2015 , 10:48   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #2

This tutorial maybe better to be in Zombie Plague section instead general AMX section. This are the same for the other two tutorials:

1. https://forums.alliedmods.net/showthread.php?t=275816
2. https://forums.alliedmods.net/showthread.php?t=275813

Last edited by zmd94; 12-09-2015 at 10:48.
zmd94 is offline
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 12-09-2015 , 11:15   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #3

Quote:
Originally Posted by zmd94 View Post
This tutorial maybe better to be in Zombie Plague section instead general AMX section. This are the same for the other two tutorials:

1. https://forums.alliedmods.net/showthread.php?t=275816
2. https://forums.alliedmods.net/showthread.php?t=275813
welcome my friend mohammed ^^ .
when i finished my lessons i will moved to zombie plague section.
__________________
arvEL. is offline
Send a message via Skype™ to arvEL.
iLlegalzp
Member
Join Date: Dec 2015
Location: Burgas
Old 12-10-2015 , 14:56   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #4

I can't find commas module
__________________
iLlegalzp is offline
Send a message via Skype™ to iLlegalzp
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 12-10-2015 , 15:15   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #5

Quote:
Originally Posted by iLlegalzp View Post
I can't find commas module
Attached Files
File Type: inc Commas.inc (722 Bytes, 194 views)
__________________
arvEL. is offline
Send a message via Skype™ to arvEL.
iLlegalzp
Member
Join Date: Dec 2015
Location: Burgas
Old 12-10-2015 , 16:08   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #6

Okay but now i getting these errors:

// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(45) : error 010: invalid function or declaration
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 017: undefined symbol "g_ammopacks"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : warning 215: expression has no effect
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 001: expected token: ";", but found "]"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 029: invalid expression, assumed zero
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : fatal error 107: too many error messages on one line



Line 45 - http://snag.gy/9wMEM.jpg

Line 59 - http://snag.gy/Y472G.jpg
__________________
iLlegalzp is offline
Send a message via Skype™ to iLlegalzp
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 12-10-2015 , 16:14   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #7

Quote:
Originally Posted by iLlegalzp View Post
Okay but now i getting these errors:

// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(45) : error 010: invalid function or declaration
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 017: undefined symbol "g_ammopacks"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : warning 215: expression has no effect
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 001: expected token: ";", but found "]"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 029: invalid expression, assumed zero
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : fatal error 107: too many error messages on one line



Line 45 - http://snag.gy/9wMEM.jpg

Line 59 - http://snag.gy/Y472G.jpg
first replace this line:

PHP Code:
zp_get_user_ammo_packs 
to:

PHP Code:
native zp_get_user_ammo_packs(id); 
__________________
arvEL. is offline
Send a message via Skype™ to arvEL.
iLlegalzp
Member
Join Date: Dec 2015
Location: Burgas
Old 12-10-2015 , 16:17   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #8

Okay, now we fixes one error but i still getting errors

// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 017: undefined symbol "g_ammopacks"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : warning 215: expression has no effect
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 001: expected token: ";", but found "]"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 029: invalid expression, assumed zero
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : fatal error 107: too many error messages on one line
__________________
iLlegalzp is offline
Send a message via Skype™ to iLlegalzp
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 12-10-2015 , 16:22   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #9

Quote:
Originally Posted by iLlegalzp View Post
Okay, now we fixes one error but i still getting errors

// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 017: undefined symbol "g_ammopacks"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : warning 215: expression has no effect
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 001: expected token: ";", but found "]"
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : error 029: invalid expression, assumed zero
// D:\OriginalZM\cstrike\addons\amxmodx\scriptin g\ZombieWorld.sma(59) : fatal error 107: too many error messages on one line
replace place this codes:

PHP Code:
public Leader()
{
    new 
iAmmoPacks
    
new iLeader GetLeader_Ammo(iAmmoPacks)       
    new 
szName[32]
    
get_user_nameiLeaderszName31 )         
    static 
PacksString[16];
    
AddCommas(g_ammopacks[iLeader], PacksString15)
    
client_print_color0Grey"^x04[ZP]^x01 The packs leader is ^3%s ^1@ ^4%s packs"szNamePacksString)
    
set_task(0.1"Leader_Frags")
}

public 
Leader_Frags()
{
    new 
iFrags
    
new iLeader GetLeader_Frags(iFrags)        
    new 
szName[32]
    
get_user_nameiLeaderszName31 )                 
    
client_print_color0Grey"^x04[ZP]^x01 The frags leader is ^3%s ^1@ ^4%d frags"szNameiFrags
}

GetLeader_Ammo( &iAmmoPacks )
{
    new 
iPlayers[32], iNumidiiLeaderiPacks
    get_players
iPlayersiNum"ch" )
    for ( 
0iNumi++ )
    {
    
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], iNumidiiLeaderiFrag
    get_players
iPlayersiNum"ch" )
    for ( 
0iNumi++ )
    {
    
id iPlayers[i]
    
iFrag get_user_frags(id)
    if ( 
iFrag iFrags )
    {
    
iFrags iFrag
    iLeader 
id
    
}
    }
    return 
iLeader;

and put it in last zp main codes:

example about place:

http://snag.gy/hksLv.jpg
__________________

Last edited by arvEL.; 12-10-2015 at 16:58.
arvEL. is offline
Send a message via Skype™ to arvEL.
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 12-10-2015 , 20:12   Re: [Tutorial] Third lesson in a series develop [ZPA 1.61] - Add Leader Frags + Packs
Reply With Quote #10

Dont use this native
PHP Code:
zp_get_user_ammo_packs(id
when you already have
PHP Code:
g_ammopacks[id
lol

Last edited by Chihuahuax; 12-10-2015 at 20:13.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
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 23:20.


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