AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Only on first kill (https://forums.alliedmods.net/showthread.php?t=127231)

DoviuX 05-18-2010 15:33

Only on first kill
 
How to detect if Survivor killed a hunter first time and the survivor gets a achieviment , but only when first time , and save if that player has an achieviment

PHP Code:

public plugin_init()
{
        
register_event("DeathMsg""event_deathmsg3""a")
}

public 
event_deathmsg3(id)
{
        new 
victim read_data(2)
        new 
attacker read_data(1)

        if(
get_user_team(victim) == CS_TEAM_T && InfectedClass[victim] == 0)
        {
                
set_hudmessage(25500, -1.00.5500.02.02.01.0, -1);
                
ShowSyncHudMsg(attacker"[L4D]: You gained a hunter killer achieviment!");

                
HunterAchieviment[attacker] = true;
        }



Bugsy 05-18-2010 19:54

Re: Only on first kill
 
If the player always gets achievement on his first kill with those conditions then you can just check if has yet gotten the achievement. I don't know if you are planning on taking action in a different function on first kill so I added a separate variable. I assume you want the first kill variable reset at each player spawn?

I hope you don't mind hamsandwich. Untested.
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <cstrike>

const MaxPlayers 32;

new 
InfectedClassMaxPlayers ];
new 
bool:g_bHunterAchievimentMaxPlayers ];
new 
bool:g_bFirstKillMaxPlayers ];
new 
g_HUDSyncObj;

public 
plugin_init()
{
    
RegisterHamHam_Spawn "player" "fwHamSpawn_Post" );
    
RegisterHamHam_Killed "player" "fwHamKilled" );
    
    
g_HUDSyncObj CreateHudSyncObj();
}

public 
fwHamSpawn_Postid )
{
    
g_bFirstKillid ] = true;
}

public 
fwHamKillediVictim iKiller iShouldGib )
{
    if ( 
iVictim == iKiller )
        return 
HAM_IGNORED;
        
    
/*If - killers first kill
         - killer has not yet gotten achievement
         - victim is not infected class ( == 0 )
         - victim is a terrorist                 */
         
    
if( g_bFirstKilliKiller ] && !g_bHunterAchievimentiKiller ] && !InfectedClassiVictim ] && ( cs_get_user_teamiVictim ) == CS_TEAM_T ) )
    {
        
set_hudmessage(25500, -1.00.5500.02.02.01.0, -1);
        
ShowSyncHudMsgiKiller g_HUDSyncObj "[L4D]: You gained a hunter killer achievement!");
    
        
g_bHunterAchievimentiKiller ] = true;
    }
    
    
g_bFirstKilliKiller ] = false;
    
    return 
HAM_IGNORED;



DoviuX 05-19-2010 07:27

Re: Only on first kill
 
Thanks , but i need that the server save if player already gotten the achieviment and when he came back to the server he still had that achieviment.

DoviuX 05-19-2010 08:13

Re: Only on first kill
 
By the way when i kill not hunter but something like boomer it gives achievement

Bugsy 05-19-2010 08:45

Re: Only on first kill
 
Quote:

Originally Posted by DoviuX (Post 1184782)
Thanks , but i need that the server save if player already gotten the achieviment and when he came back to the server he still had that achieviment.

Does this reset at map change?

DoviuX 05-19-2010 08:53

Re: Only on first kill
 
Yes , or when player reconnects.

And what about when i kill zombie not hunter but another class zombie it still show that i killed hunter.

Bugsy 05-19-2010 09:21

Re: Only on first kill
 
Quote:

Originally Posted by DoviuX
[..] and when he came back to the server he still had that achieviment.

Quote:

Originally Posted by bugsy
Does this reset at map change?

Quote:

Originally Posted by DoviuX (Post 1184860)
Yes , or when player reconnects.

You contradict yourself, unless I am just not understanding you. You say you want it to remember achievement if he reconnects, then you say reset the achievement at map change or when player reconnects.

DoviuX 05-19-2010 10:53

Re: Only on first kill
 
What i mean is player gets the achieviment when kills hunter (but when you kill even not hunter you get the achieviment) and he disconnects or map restarts he still had that achieviment. Something like xp in nVault.

Bugsy 05-20-2010 08:49

Re: Only on first kill
 
Quote:

Originally Posted by DoviuX (Post 1184975)
What i mean is player gets the achieviment when kills hunter (but when you kill even not hunter you get the achieviment) and he disconnects or map restarts he still had that achieviment. Something like xp in nVault.

Ok so explain what you want...

?

Player dies - keep achievement
player reconnect - keep achievement
map\server restart - keep achievement

DoviuX 05-20-2010 11:49

Re: Only on first kill
 
Yes , and there is one problem when i kill not hunter but another class zombie i still get the achieviment.


All times are GMT -4. The time now is 03:46.

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