AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   JailBreak packets (https://forums.alliedmods.net/showthread.php?t=189893)

GhostMan 07-12-2012 05:33

JailBreak packets
 
PHP Code:

register_logevent("logevent_round_end"2"1=Round_End")  

logevent_round_end(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_CT && is_user_alive(id))
    {    
        
g_jbpacks[id] += 5
        ChatColor
(id"| AMX | You got 5 JB Packets for ending this round alive." )
    }


Do i wrote all correct if i want to give 5 JP packets to alive ct on round end? It is jb shop 3.0 http://forums.alliedmods.net/showthread.php?t=118107

By the way, one more question from same plugin.

If i want that for players with T flag would be given 2x more JB Packs this is the best way to do it or is there more optimised or something?

PHP Code:

public fw_player_killed(victimattackershouldgib)
{

    if(!
is_user_connected(victim) || !is_user_connected(attacker) || attacker == victim || get_playersnum() < 4)
    return 
HAM_IGNORED

    
if(get_user_team(attacker) == 1)
    {
        if(
get_user_flags(attacker) & ADMIN_LEVEL_H)
        {
            
g_jbpacks[attacker] += get_pcvar_num(g_killjp) * 2
        
}
        else
        {
            
g_jbpacks[attacker] += get_pcvar_num(g_killjp)
        }
        
        if(
get_pdata_int(victim75) == HIT_HEAD)
        {
            if(
get_user_flags(attacker) & ADMIN_LEVEL_H)
            {
                
g_jbpacks[attacker] += get_pcvar_num(g_killhsjp) * 2
            
}
            else
            {
                
g_jbpacks[attacker] += get_pcvar_num(g_killhsjp)
            }
        }
    }
    return 
HAM_IGNORED



Backstabnoob 07-12-2012 07:06

Re: JailBreak packets
 
The first part won't work because Round_End doesn't pass any arguments; you need to loop through the alive players using get_players.

For the second part, cache get_user_flags( attacker ) and get_pcvar_num( g_killhsjp ) at the beginning of the function so you don't need to call the natives as much as you do.

GhostMan 07-12-2012 08:05

Re: JailBreak packets
 
You mean like this?
PHP Code:

public logevent_round_end(id)
{
    new 
players[32], num
    get_players
(playersnum"a")
   
    for(new 
inumi++)
    {
        new 
tid players[i]
        
        if(
cs_get_user_team(tid) == CS_TEAM_CT && is_user_alive(tid))
        {    
            
g_jbpacks[tid] += 5
            ChatColor
(tid"| AMX | You got 5 JB Packets for ending this round alive." )
        }
    }


And i'm not sure about second part, could you please give an example?

Backstabnoob 07-12-2012 08:35

Re: JailBreak packets
 
PHP Code:

public logevent_round_end(id

=>
PHP Code:

public logevent_round_end( ) 

Even though it shouldn't do any harm, it's always better if it's as it should be.

Remove is_user_alive check from the loop, it's useless as you're already looping only through alive players (flag "a")
Remove cs_get_user_team check and add flag "e" to get_players, then add an extra parameter "CT":
PHP Code:

get_playersplayersnum"ae""CT" 


For the second part;
Code:
public fw_player_killed(victim, attacker, shouldgib) {     new HasFlag = _:( get_user_flags( attacker ) & ADMIN_LEVEL_H ), _cacheCvar = get_pcvar_num( g_killsjp )     if(!is_user_connected(victim) || !is_user_connected(attacker) || attacker == victim || get_playersnum() < 4)     return HAM_IGNORED     if(get_user_team(attacker) == 1)     {         if( HasFlag )         {             g_jbpacks[attacker] += _cacheCvar * 2         }         else         {             g_jbpacks[attacker] += _cacheCvar         }                 if(get_pdata_int(victim, 75) == HIT_HEAD)         {             if( HasFlag )             {                 g_jbpacks[attacker] += _cacheCvar * 2             }             else             {                 g_jbpacks[attacker] += _cacheCvar             }         }     }     return HAM_IGNORED }

You could also change this:
Code:
        if(HasFlag)         {             g_jbpacks[attacker] += _cacheCvar * 2         }         else         {             g_jbpacks[attacker] += _cacheCvar         }
to this:
Code:
g_jbpacks[ attacker ] += HasFlag ? _cacheCvar * 2 : _cacheCvar

Same for the second if/else.

GhostMan 07-12-2012 10:59

Re: JailBreak packets
 
Im not sure if your given code for second part is a corrert, becouse for killing CT it gives 3 JB packts (just an e.g.) and for doing it with HS it gives just +1, so in sum it will be 4 jb packets. And if look in your code for killing a ct it gives 3 packets and if you do it with HS it also gives 3 packets, so in sum it will be 6 packets.


Now, one more question, i would like to print for player how many packets he gets, so is there any better way than this?

PHP Code:

public fw_player_killed(victimattackershouldgib)
{

    if(!
is_user_connected(victim) || !is_user_connected(attacker) || attacker == victim || get_playersnum() < 4)
    return 
HAM_IGNORED
    
    
new killvip[attacker], kill[attacker], killviphs[attacker], killhs[attacker]

    if(
get_user_team(attacker) == 1)
    {
        if(
get_user_flags(attacker) & ADMIN_LEVEL_H)
        {
            
killvip[attacker] = true
            g_jbpacks
[attacker] += get_pcvar_num(g_killjp) * 2
        
}
        else
        {
            
kill[attacker] = true
            g_jbpacks
[attacker] += get_pcvar_num(g_killjp)
        }
        
        if(
get_pdata_int(victim75) == HIT_HEAD)
        {
            if(
get_user_flags(attacker) & ADMIN_LEVEL_H)
            {
                
killviphs[attacker] = true
                g_jbpacks
[attacker] += get_pcvar_num(g_killhsjp) * 2
            
}
            else
            {
                
killhs[attacker] = true
                g_jbpacks
[attacker] += get_pcvar_num(g_killhsjp)
            }
        }
        
        if(
killviphs[attacker]) {
            
ChatColor(attacker"|AMX| You got %d JP Packets for killing a CT + %d JB Packets for doing it with HS."get_pcvar_num(g_killjp) * 2get_pcvar_num(g_killhsjp) * 2)
            
killviphs false
        
}
        else if(
killhs[attacker]) {
            
ChatColor(attacker"|AMX| You got %d JP Packets for killing a CT + %d JB Packets for doing it with HS."get_pcvar_num(g_killjp), get_pcvar_num(g_killhsjp))
            
killhs[attacker] = false
        
}
        else if(!(
killviphs[attacker]) && killvip[attacker]) {
            
ChatColor(attacker"|AMX| You got %d JP Packets for killing a CT."get_pcvar_num(g_killjp))
            
killvip[attacker] = false
        
}
        else if(!(
killhs[attacker]) && kill[attacker]) {
            
ChatColor(attacker"|AMX| You got %d JP Packets for killing a CT."get_pcvar_num(g_killjp))
            
kill[attacker] = false
        
}
        
    }
    return 
HAM_IGNORED




All times are GMT -4. The time now is 15:22.

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