AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Take The Glow (https://forums.alliedmods.net/showthread.php?t=236958)

ezio_auditore 03-15-2014 04:35

Take The Glow
 
1 Attachment(s)
OK!!

This is a very simple plugin;
in this plugin, a random player glows on round start
when he gets killed, his glow is transferred to the killer

on round end, everyone is killed expect the glowing player

But my method of transferring the glow don't work
I guess the problem is with HookKilled function

I tried this
PHP Code:

//in plugin_init
RegisterHam(Ham_Killed"player" "HookKilled"

later on
PHP Code:

 
new kID
 
public HookKilled(victimkillershouldgib)
{
 if (
isGlowing(victim)){
  
kID killer
  glow
(kID255,255,255)
  
unglow(victim)
  
get_user_name(kIDsName32)//It is a bugfix
  
get_user_team(kIDsTeam32)
  
glowmsg(sName,sTeam)
 }


So, where I am doing wrong??

the .sma is in attachments

Kiske 03-15-2014 10:39

Re: Take The Glow
 
Your code have some mistakes.

  1. PHP Code:

    public roundstart(){
        new 
    ID random_num(get_maxplayers() - 1)
        
        if (
    get_pcvar_num(g_toggle) == 1glow(ID255255255)
        
        
    get_user_name(IDsName32)
        
    get_user_team(IDsTeam32)
        
        
    glowmsg(sName,sTeam)


    You need to check if are players playing, then, check if the 'ID' is alive, in other case, you need to repeat the process.


  2. Why use 'isGlowing(index)' instead of 'g_IsGlowing[index]' directly ?


  3. PHP Code:

    public HookKilled(victimkillershouldgib)
    {
        if (
    isGlowing(victim)){
            
    kID killer
            glow
    (kID255,255,255)
            
    unglow(victim)
            
    get_user_name(kIDsName32)//It is a bugfix
            
    get_user_team(kIDsTeam32)
            
    glowmsg(sName,sTeam)
        }


    You need to check if the 'killer' is alive.
    And what happens if the 'killer' throw a grenade, he dies, and when the grenade explodes he kills the player with glow ?


  4. PHP Code:

    stock glowmsg(glower_name[], glower_team[])
    {
        for (new 
    <= get_maxplayers() ; i++){    
                
    client_print(print_chat "[AMXX] %s (%s) is glowing, kill him to take his glow",glower_name,glower_team)
            }


    If you idea is send a message to all clients, use 0 in the first parameter of client_print.
    Quote:

    /* Sends message to player. Set index to 0 to send text globaly. */
    native client_print(index,type,const message[],any:...);

  5. Use a var like 'g_MaxPlayers' to store 'get_maxplayers();' in 'plugin_init', and then use this var later in the loop of 'roundend' and here: 'new ID = random_num(1 , get_maxplayers() - 1)'


  6. You need to reset 'g_IsGlowing[index]' when a player is connect or disconnect.


  7. What happens if the player with glow is disconnect ?

And sorry for my english, I am learning and practicing.


All times are GMT -4. The time now is 06:01.

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