Raised This Month: $ Target: $400
 0% 

Take The Glow


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ezio_auditore
Senior Member
Join Date: May 2013
Old 03-15-2014 , 04:35   Take The Glow
Reply With Quote #1

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
Attached Files
File Type: sma Get Plugin or Get Source (take_the_glow.sma - 557 views - 2.2 KB)
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
Kiske
Veteran Member
Join Date: May 2009
Old 03-15-2014 , 10:39   Re: Take The Glow
Reply With Quote #2

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.
__________________


Last edited by Kiske; 03-15-2014 at 10:45.
Kiske is offline
Send a message via Skype™ to Kiske
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 06:01.


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