Raised This Month: $32 Target: $400
 8% 

Explain a part of "Knife Kill Bonus" plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VarmaRitik
Senior Member
Join Date: Jul 2014
Location: India
Old 02-28-2015 , 04:08   Explain a part of "Knife Kill Bonus" plugin
Reply With Quote #1

Hello,
Someone please explain me this part :
Code:
public onDeathMsgEvent()
{
    new id = read_data(1)
    
    new szWeapon[32]
    read_data(4, szWeapon, charsmax(szWeapon))
    
    if(equal(szWeapon, "knife") && is_user_alive(id))
    {
        new szName[32], szName2[32]
        get_user_name(id, szName, charsmax(szName))
        get_user_name(read_data(2), szName2, charsmax(szName2))
        
        set_hudmessage(255, 0, 0, 0.02, 0.2, 1, 0.1, 6.0, 0.1, 0.1, -1)
        ShowSyncHudMsg(0, g_iSync, "Player %s knifed %s and got 3frags+15HP+Speed", szName, szName2)
        
        client_cmd(id, "mp3 play %s", g_szSound)
        
        set_user_health(id, get_user_health( id ) + 15 )
        
        g_bHasSpeed[id] = true
        remove_task(id + TASK_ID)
        set_task(10.0, "taskRemoveSpeed", id + TASK_ID)
        set_user_maxspeed(id, FAST_SPEED)
        set_user_frags( id, get_user_frags( id ) + 3 )
    }
}
Thank You for your valuable time.
VarmaRitik is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-28-2015 , 05:53   Re: Explain a part of "Knife Kill Bonus" plugin
Reply With Quote #2

You can't expect all the time peoples will do everything for you. Pickup line by line, go to amxmodx.org/api and see what every native does. Don't be lazy, you won't learn anything if we just give you the answer.
__________________
HamletEagle is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-28-2015 , 07:20   Re: Explain a part of "Knife Kill Bonus" plugin
Reply With Quote #3


But to show you how you should think:

1. First line is new id = read_data(1)
  • Break it into pieces.
  • First is new id -> it initialize a variable called "id"
  • read_data(1)
    • Go to amxmodx.org/api and search for read_data
    • Read the description: "Retrieves values from a client message/For use within callbacks registered with register_event()."
    • Now you know that this native read the data from an event. But why 1 ? We assume that this 1 in an event param. Go on the events page and search for DeathMsg(your public name tells me that this is DeathMsg event): https://wiki.alliedmods.net/Half-Life_1_Game_Events
    • At DeathMsg, for Counter-Strike you can see it's structure:
    • Code:
      Structure:
      byte	KillerID
      byte	VictimID
      byte	IsHeadshot
      string	TruncatedWeaponName
      • We want to find what that 1 is, so we look at the first byte, which is KillerID
      • You just discovered what this native do, it get the killer index from DeathMsg event
  • Now it save it in the variable called id

Do the same for the others. It may look hard, but you don't have other option, this is the only way of learning something and fully understanding it.

__________________

Last edited by HamletEagle; 02-28-2015 at 07:23.
HamletEagle is offline
VarmaRitik
Senior Member
Join Date: Jul 2014
Location: India
Old 03-01-2015 , 02:30   Re: Explain a part of "Knife Kill Bonus" plugin
Reply With Quote #4

HamletEagle,

Thank You so much.
VarmaRitik 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 19:36.


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