Raised This Month: $ Target: $400
 0% 

How to add DMG to weapon


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-09-2014 , 06:34   Re: How to add DMG to weapon
Reply With Quote #4

Code:
if(is_user_alive(id))
{
	ColorChat(id, NORMAL, "%s You are ^4dead^1.", g_szPrefix)
	client_cmd(id, "spk %s", g_szNo)
}
What?! I think you forgot the ! sign before is_user_alive
Also, if you want to stop the function, use else after the check, or return something inside it, so the function will stop.
It's better to use the item variable, instead of getting menu info. Just make a
PHP Code:
new key item 
and then you may use the same switch between key.
Now, on the thread. You should register Ham_TakeDamage like this:
PHP Code:
RegisterHam(Ham_TakeDamage"player""Event_TakeDamage"
I see you have already made a bool for the user having golden ak47, so we can use it in the ham function to check if the user holds golden ak and then multiple his damage.
Like this:
PHP Code:
public Event_TakeDamage(victiminflictorattackerFloat:damagedmgbits)
{
    if(
is_user_alive(attacker) && get_user_weapon(attacker) == CSW_AK47 && Golden[attacker])//Checking if the user holds AK47 and it's golden
        
SetHamParamFloat(4damage 2//Here we multiple his damage! The second param is the value of the damage. 
        //Now it's multiplied by 2, but you can increase this number to higher or lower one.

P.S.: I see you reset the bool only on spawn. But if player drops his golden ak47, he will still have that damage increase with another ak47, which is not golden. So you may set the bool to false on ak47 dropping, if it's true when the user drops the ak47.

Also, you may register cvars in variables, so it'll be more easy to use them. And it's better to use get_pcvar_num instead of get_cvar_num, because it's faster.

And you may use read_data(2) in CurWeapon event insted of get_user_weapon, because I think it's more proper.

In the function of the menu, where you give the golden ak47, you don't actually give it to him, but only check if he already has one. So you will have to give_item(id, "weapon_ak47") and then there is no need to check if he already has one, because you gave him. Otherwise, what if he hasn't got ak47? No sense. I'm not really sure if giving the item will automaticaly switch to it, but I think so.

In the menu, you don't have to addblank 0 and then switch it and destroy the menu there. Just use that check in the handlers and it's all okay.
PHP Code:
    if(item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    

The code with all changes precached.
Attached Files
File Type: sma Get Plugin or Get Source (Shop.sma - 587 views - 3.6 KB)
__________________

Last edited by Flick3rR; 06-09-2014 at 06:52.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
 



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 09:39.


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