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

Hud Message Parameter


Post New Thread Reply   
 
Thread Tools Display Modes
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 01-26-2015 , 06:08   Re: Hud Message Parameter
Reply With Quote #11

^Then how is he going to get the player remaning bullet?
@Obada: Show us the whole code.
RateX is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 01-26-2015 , 06:12   Re: Hud Message Parameter
Reply With Quote #12

Here is the full Code:-

Spoiler
Obada is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 01-26-2015 , 21:44   Re: Hud Message Parameter
Reply With Quote #13

Quote:
Here is the full Code:-
Don't just C&P code like that.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>
#include <engine>
#include <cstrike>
#include <nvault>
#include <played_time>
#include <hamsandwich>

#define PLUGIN "SoloGunner Mode"
#define VERSION "1.0"
#define AUTHOR "Khalid :)"

/* - - - - - -  Edit Starts Here  - - - - - - - - - - - - - - - - - - - - - - - - - - */

#define ADMIN_FLAG        ADMIN_BAN
#define GOLDEN_FLAG        ADMIN_LEVEL_H
#define SILVER_FLAG        ADMIN_LEVEL_G

#define ACTIVATE_DELAY        20.0

#define SOLO_AMMO        26
#define SOLO_MODEL        "vip"
#define TASK_HUD    432548

// Times
#define MINS_FOR_SOLO_KILL    5
#define MINS_DECREMENT_SOLO_KNIFED 350    
#define MINS_FOR_SOLO_KILLER    100

#define SOLO_SUICIDE_TIME_DECREMENT    350
#define SOLO_DISCONNECT_TIME_DECREMENT    350

// Limits
#define ADMIN_ACTIVATES 3
#define GOLDEN_ACTIVATES 2
#define SILVER_ACTIVATES 1

/* - - - - - -  Edit Ends Here  - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#define FINAL            (ADMIN_FLAG | SILVER_FLAG | GOLDEN_FLAG)

#define OFFSET_MAPZONES 235

#define IsValidPlayer(%1) (1 <= %1 <= g_iMaxPlayers)

new bool:g_bRunning false
new g_iModeActivates[33], g_iSoloIdFloat:g_flRoundStartGameTime

new gMsgIdCurWeapon

new g_szOldModel[20]

new 
gVaultg_iMaxPlayers

enum _
:Levels
{
    
ADMIN,
    
GOLDEN,
    
SILVER
}

new 
g_iActivateTimes[Levels] = {
    
ADMIN_ACTIVATES,
    
GOLDEN_ACTIVATES,
    
SILVER_ACTIVATES
}

/* 
The player who activates this mode becomes a Solo Gunner and the following happens:
The solo gunner will have a knife and a USP gun with 26 bullets only.

The rest of the players will only be able to carry a knife.

The solo gunner shall get 5 minutes added to his/her total time on every player he/she kills. -- wait

If the solo gunner gets knifed and killed, he/she will lose 350 minutes of his/her total time and a bell-like sound will be played to inform others. -- wait

If a player kills a solo gunner, 100 minutes will be added to his/her total time. -- wait

If the solo gunner disconnects from the server (to avoid being killed), he/she will lose 350 minutes. -- wait

Solo Gunner Mode is activated for one round only. Everything would return to normal by next round.

Silvers can activate this mode once per day, Goldens twice per day, and Administrators three times per day. However, to keep this mode interesting, the server will allow Solo Gunner mode to be activated a total of 3 times per map.
*/

public plugin_precache()
{
    new 
szFile[60]
    
formatex(szFilecharsmax(szFile), "models/player/%s/%s.mdl"SOLO_MODELSOLO_MODEL)
    
    
precache_model(szFile)
    
    
precache_sound("bell.wav")
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("ad_solo""AdminActivate", FINAL)
    
    
register_concmd("amx_reset_times""AdminResetTimes"ADMIN_RCON"<name> - Resets current mod activates")
    
    
register_touch("weaponbox""player""fw_BlockWeaponPickUp")
    
register_touch("armoury_entity""player""fw_BlockWeaponPickUp")
    
    
register_forward(FM_SetClientKeyValue"fw_SetClientKeyValue")
    
    
register_event("CurWeapon""eCurWeapon""b")
    
register_event("HLTV""eNewRound""a""1=0""2=0")
    
register_event("DeathMsg""eDeath""a")
    
register_logevent("RoundEnd"2"1=Round_End")
    
    
register_message(get_user_msgid("StatusIcon"), "message_StatusIcon")
    
    
gMsgIdCurWeapon get_user_msgid("CurWeapon")
    
    
g_iMaxPlayers get_maxplayers()
    
    
// I was lazy to use files, nvault is faster and easier :D
    
gVault nvault_open("SoloUses")
    
    if(
gVault == INVALID_HANDLE)
    
set_fail_state("Couldn't open Solo Activates vault file")
    
    new 
szCurrentDay[6], szVaultDay[6], iSysTime
    format_time
(szCurrentDaycharsmax(szCurrentDay), "%j", (iSysTime get_systime()))
    
    
nvault_get(gVault"day"szVaultDaycharsmax(szVaultDay))
    
    if(!
equal(szCurrentDayszVaultDay))
    {
        
nvault_prune(gVault0iSysTime 28)
        
nvault_remove(gVault"day")
        
nvault_set(gVault"day"szCurrentDay)
        
        
log_amx("The day has changed! Reseting Ghost Activates")    
    }
}

public 
plugin_end()
{
    
nvault_close(gVault)
}

public 
client_putinserver(id)
{
    if(
get_user_flags(id) & FINAL)
    
g_iModeActivates[id] = LoadUses(id)
}

public 
client_disconnect(id)
{
    if(
g_bRunning && id == g_iSoloId)
    {
        
set_user_playedtime(idget_user_playedtime(id) - SOLO_DISCONNECT_TIME_DECREMENT)
    }
    
    if(
get_user_flags(id) & FINAL)
    
SaveUses(id)
}

public 
AdminResetTimes(idlevelcid)
{
    if(!
cmd_access(idlevelcid2))
    return 
PLUGIN_HANDLED
    
    
static szArg[32]
    
read_argv(1szArgcharsmax(szArg))
    
    new 
iPlayer cmd_target(idszArgCMDTARGET_ALLOW_SELF)
    
    if(
szArg[0] == '*' && !szArg[1])
    {
        
console_print(id"Reseted Solo Activates for this day for all connected players (admin\golden\silver)")
        
        
arrayset(g_iModeActivatessizeof(g_iModeActivates))
        
        return 
PLUGIN_HANDLED
    
}
    
    if(!
iPlayer)
    {
        
console_print(id"Player could not be found")
        return 
PLUGIN_HANDLED
    
}
    
    
get_user_name(iPlayerszArgcharsmax(szArg))
    
g_iModeActivates[id] = 0
    
    console_print
(id"Reseted SoloGunner Activates for player %s"szArg)
    return 
PLUGIN_HANDLED
}

public 
AdminActivate(idlevelcid)
{
    if(!
cmd_access(idlevelcid1))
    return 
PLUGIN_HANDLED
    
    
if(g_bRunning)
    {
        
console_print(id"*** Mode is already running")
        return 
PLUGIN_HANDLED
    
}
    
    if(!
is_user_alive(id))
    {
        
console_print(id"*** You must be alive to activate the mode")
        return 
PLUGIN_HANDLED
    
}
    
    new 
iFlags get_user_flags(id)
    if(!
CanActivate(idiFlags))
    {
        return 
PLUGIN_HANDLED
    
}
    
    
g_bRunning trueg_iSoloId id
    
    
new iPlayers[32], iNumiPlayer
    get_players
(iPlayersiNum"ach")
    
    for(new 
iiNumi++)
    {
        
iPlayer iPlayers[i]
        
strip_user_weapons(iPlayer)
        
        
give_item(iPlayer"weapon_knife")
        
        if(
iPlayer == id)
        {
            
give_item(iPlayer"weapon_usp")
            
cs_set_user_bpammo(iPlayerCSW_USPSOLO_AMMO)
            
            
get_user_model(iPlayerg_szOldModelcharsmax(g_szOldModel))
            
set_user_model(iPlayerSOLO_MODEL)
        }
    }
    
    new 
szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
    
client_print(0print_chat"*** %s %s: Activated SoloGunner mode. Everything will return to normal next round.", ( iFlags ADMIN_FLAG "Administrator" : ( iFlags GOLDEN_FLAG "Golden Player" "Silver Player" ) ), szName)
    
client_print(0print_chat"*** Everyone will only have a knife in this round and %s will only have one gun and a knife."szName)
    
client_print(0print_chat"*** If %s gets killed in this round, 350 minutes will be deducted from his/her total time."szName)
    
client_print(0print_chat"*** If you are in %s's team, try to help him/her by killing the opposing team."szName)
    
    
set_task(1.0"hud_message"id+TASK_HUD)
    
    
g_iModeActivates[id]++
    
    return 
PLUGIN_HANDLED
}

public 
hud_message(taskid)
{
    new 
id taskid TASK_HUD
    
if(!is_user_connected(id))
    {
        
remove_task(taskid)
        return
    }
    new 
iFlags get_user_flags(id)
    new 
szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
set_hudmessage(2552550, -1.00.2506.01.0
    
show_hudmessage(0"%s %s Activated SoloGunner mode^nBullets Remaining: %d", ( iFlags ADMIN_FLAG "Administrator" : ( iFlags GOLDEN_FLAG "Golden Player" "Silver Player" ) ), szNamecs_get_user_bpammo(idCSW_USP))
        
    
set_task(1.0"hud_message"taskid)

    
public 
fw_BlockWeaponPickUp(iTouchediToucher)
return 
g_bRunning PLUGIN_HANDLED PLUGIN_CONTINUE

// Thanks to MeRcyLeZZ for model change stuff
public fw_SetClientKeyValueid, const infobuffer[], const key[] )
{
    if(!
g_bRunning)
    return 
FMRES_IGNORED
    
    
if ( id == g_iSoloId && equalkey"model" ) )
        {
        static 
szCurrentModel[32]
        
get_user_modelidszCurrentModelcharsmaxszCurrentModel ) )
        
        if ( !
equalszCurrentModel"vip" ) )
            
set_user_modelid"vip")
        
        return 
FMRES_SUPERCEDE;
    }
    
    return 
FMRES_IGNORED;
}

public 
eNewRound()
{
    
g_flRoundStartGameTime get_gametime()
}

public 
eCurWeapon(id)
{
    if(!
is_user_alive(id) || !g_bRunning)
    return;
    
    new 
iWeaponId read_data(2)
    
    if(
id != g_iSoloId && iWeaponId != CSW_KNIFE)
    {
        
// Just in case
        
engclient_cmd(id"weapon_knife")
        
        
message_begin(MSG_ONEgMsgIdCurWeapon,_id)
        
write_byte(1)
        
write_byte(CSW_KNIFE)
        
write_byte(-1)
        
message_end()
    }
}

public 
RoundEnd()
{
    
g_bRunning false
    set_user_model
(g_iSoloIdg_szOldModel)
}

public 
eDeath()
{
    if(!
g_bRunning)
    return;
    
    new 
iKiller read_data(1)
    new 
iVictim read_data(2)
    
    new 
szWeapon[25]
    
    
read_data(4szWeaponcharsmax(szWeapon))
    
    
// Solo killed someone
    
if(iKiller == g_iSoloId && iVictim != g_iSoloId)
    {
        
client_print(iKillerprint_chat"*** You have gained %d minutes for killing"MINS_FOR_SOLO_KILL)
        
set_user_playedtime(iKillerget_user_playedtime(iKiller) + MINS_FOR_SOLO_KILL)
    }
    
    
// Suicide
    
else if( (!iKiller || !IsValidPlayer(iKiller) || iKiller == iVictim) && iVictim == g_iSoloId )
    {
        
client_print(iVictimprint_chat"*** %d minutes have been taken from you for suiciding"SOLO_SUICIDE_TIME_DECREMENT)
        
set_user_playedtime(iVictimget_user_playedtime(iVictim) - SOLO_SUICIDE_TIME_DECREMENT)
    }
    
    
// Someone killed solo
    
else if( iKiller != iVictim && iVictim == g_iSoloId && IsValidPlayer(iKiller) )
    {
        static 
szName[32]; get_user_name(iKillerszNamecharsmax(szName))
        
        if(
equal(szWeapon"knife"))
        {
            
// Play bell sound
            
client_cmd(0"spk ^"bell^"")
            
            
client_print(iVictimprint_chat"*** %d minutes have been taken from you for being knifed and killed"MINS_DECREMENT_SOLO_KNIFED)
            
set_user_playedtime(iVictimget_user_playedtime(iVictim) - MINS_DECREMENT_SOLO_KNIFED)
        }
        
        
client_print(0print_chat"*** %d minutes were added to %s for killing the SoloGunner"MINS_FOR_SOLO_KILLERszName)
        
set_user_playedtime(iKillerget_user_playedtime(iKiller) + MINS_FOR_SOLO_KILLER)
    }
}

public 
message_StatusIcon(msgidmsgdestid)
{
    if(
g_bRunning)
    {
        static 
szIcon[10]
        
get_msg_arg_string(2szIconcharsmax(szIcon))
        
        if(
equal(szIcon"buyzone") && get_msg_arg_int(1))
        {
            
set_pdata_int(idOFFSET_MAPZONESget_pdata_int(idOFFSET_MAPZONES) & ~(1<<0))
            return 
PLUGIN_HANDLED
        
}
    }
    
    return 
PLUGIN_CONTINUE
}

LoadUses(id)
{
    static 
szAuthId[33]; get_user_authid(idszAuthIdcharsmax(szAuthId))
    
    static 
szUses[4], iTimeStamp
    
    
if(nvault_lookup(gVaultszAuthIdszUsescharsmax(szUses), iTimeStamp))
    {
        return 
str_to_num(szUses)
    }
    
    return 
0
}

SaveUses(id)
{
    static 
szAuthId[33], szUses[4]; get_user_authid(idszAuthIdcharsmax(szAuthId))
    
    
nvault_remove(gVaultszAuthId)
    
formatex(szUsescharsmax(szUses), "%d"g_iModeActivates[id])
    
nvault_set(gVaultszAuthIdszUses)
}

CanActivate(idiFlags)
{
    if(
get_gametime() - g_flRoundStartGameTime ACTIVATE_DELAY)
    {
        
console_print(id"*** Mode connot be activated as more than %f seconds passed since round start"ACTIVATE_DELAY)
        return 
0
    
}
    
    if( 
g_iModeActivates[id] > g_iActivateTimes[get_level(iFlags)] )
    {
        
console_print(id"*** You have exceeded the SoloGunner mode activates for this day")
        return 
0
    
}
    
    return 
1
}

get_level(iFlags)
{
    if(
iFlags ADMIN_FLAG)
    return 
ADMIN
    
    
if(iFlags GOLDEN_FLAG)
    return 
GOLDEN
    
    
if(iFlags SILVER_FLAG)
    return 
SILVER
    
    
return 0
}

// Thanks to MeRcyLeZZ for model change stuff
stock set_user_modelplayer, const modelname[] )
{
    
engfuncEngFunc_SetClientKeyValueplayerengfuncEngFunc_GetInfoKeyBufferplayer ), "model"modelname )
}

stock get_user_modelplayermodel[], len )
{
    
engfuncEngFunc_InfoKeyValueengfuncEngFunc_GetInfoKeyBufferplayer ), "model"modellen )


Last edited by RateX; 01-26-2015 at 21:44.
RateX is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 01-27-2015 , 06:14   Re: Hud Message Parameter
Reply With Quote #14

Thanks man

but the hud message is being displayed even after the round has ended, it won't stop :/



PS .By the way, I don't want to create another thread for help, I'll just use this one.


The plugin I posted deals with using the natives of the played_time.amxx plugin. like adding and removing time.

The problem is that it adds/remove time, but after map change/restart/client disconnect, player's additional time (from the solo gunner plugin) gets reseted.


Thank you so much.

Last edited by Obada; 01-27-2015 at 06:16.
Obada is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-27-2015 , 16:27   Re: Hud Message Parameter
Reply With Quote #15

Check if the mode isn't active
Then remove the taskid, in the hudmessage function!
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 01-27-2015 , 21:49   Re: Hud Message Parameter
Reply With Quote #16

For the round end, in hud_message, change:
PHP Code:
if(!is_user_connected(id))
{
        
remove_task(taskid)
        return


PHP Code:
if(!is_user_connected(id) || !g_bRunning)
{
        
remove_task(taskid)
        return

RateX is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 01-28-2015 , 06:30   Re: Hud Message Parameter
Reply With Quote #17

Thanks guys, you're the best!


By the way, can you guys help me in my previous post? I'd appreciate it!
Obada is offline
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 02:08.


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