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

I need help with my plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RayCodeCSC
Junior Member
Join Date: Sep 2019
Old 09-01-2019 , 19:13   I need help with my plugin
Reply With Quote #1

Hi, I need help with my plugin. I have created a store in which I have a list with items such as "Power 1", "Power 2", etc.

and I need to do that when a player presses, for example, "Power 1", it sets the damage to 50.0. I'd like to do it through hamsandwich.

Originally I wanted to do this as follows:
Code:
public plugin_init()
{
	register_plugin("My first shop", "1.0", "RayCodeCSC")

	register_clcmd("say /test", "test_function")

	RegisterHam(Ham_TakeDamage, "player", "isDamaged")
}

public test_function(id)
{
	//What exactly do I write in brackets?
	isDamaged(victim, attacker, inflictor, Float:damage, damagebits)
}

public isDamaged(victim, attacker, inflictor, Float:damage, damagebits)
{
	if(get_user_weapon(attacker) == CSW_KNIFE)
	{
		SetHamParamFloat(4, damage = 30.0)
	}
}
But I can't work enough to call a function.
So the question is: How do I call a function?

When I tried it like this, it doesn't work for me:
Code:
isDamaged(victim, attacker, inflictor, Float:damage, damagebits)
So what do I write in brackets isDamaged() to make it public isDamaged()?

In a nutshell: I just want to explain how a function call works and possibly correct my code.

I apologize for my English, perhaps you'll understand what I want from you :-).
RayCodeCSC is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-02-2019 , 01:21   Re: I need help with my plugin
Reply With Quote #2

What's the "damage" are you trying to change? Is It fall damage, weapon damage, etc...

Between the brackets are called parameters you have to pass digits or string depends on the parameter data type

You either can pass them as numeric values or as variables that holds a value.

As you Registered a hook to the damage event of a player through ham module and provided the callfunction which is (isDamaged), every time the player gets damaged the isDamaged function will be called.

So calling it within the plugin won't make any changes.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-02-2019 at 01:25.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
thEsp
BANNED
Join Date: Aug 2017
Old 09-02-2019 , 05:10   Re: I need help with my plugin
Reply With Quote #3

Yup, you can call those functions/hooks via ExecuteHam[B] native. For more information about ham hooks check ham_const header, which tells you how to execute or register them.
thEsp is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-02-2019 , 10:00   Re: I need help with my plugin
Reply With Quote #4

Quote:
Originally Posted by thEsp View Post
Yup, you can call those functions/hooks via ExecuteHam[B] native. For more information about ham hooks check ham_const header, which tells you how to execute or register them.
Yeah unless he used that(ExecuteHam) which I totally forgot about it.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
RayCodeCSC
Junior Member
Join Date: Sep 2019
Old 09-02-2019 , 12:17   Re: I need help with my plugin
Reply With Quote #5

I don't understand how to use those variables. I tried it as follows and wrote these errors (when I tried to compile it)

Code:
test.sma(21) : error 088: number of arguments does not match definition
test.sma(28) : error 017: undefined symbol "damage"
test.sma(28) : warning 221: label name "float" shadows tag name
test.sma(28) : warning 215: expression has no effect
test.sma(28) : error 001: expected token: ";", but found ")"
test.sma(28) : error 029: invalid expression, assumed zero
test.sma(28) : fatal error 107: too many error messages on one line
Here's the script code:
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <hamsandwich>

new float:dmgSet = 30.0

public plugin_init()
{
	register_plugin("My first shop", "1.0", "RayCodeCSC")

	register_clcmd("say /test", "test_function")

	RegisterHam(Ham_TakeDamage, "player", "isDamaged")
}

public test_function(id)
{
	//What exactly do I write in brackets?
	isDamaged(float:dmgSet)
}

public isDamaged(victim, attacker, inflictor, float:dmgSet)
{
	if(get_user_weapon(attacker) == CSW_KNIFE)
	{
		SetHamParamFloat(4, damage * float:dmgSet)
	}
}
Can you please modify the code so that it is correct?
RayCodeCSC is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-02-2019 , 12:57   Re: I need help with my plugin
Reply With Quote #6

Sorry this section is not do for me but tell me how.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
RayCodeCSC
Junior Member
Join Date: Sep 2019
Old 09-02-2019 , 13:07   Re: I need help with my plugin
Reply With Quote #7

What? I do not understand you. What am I supposed to tell you?

I just need to explain how variables work. Respectively how they are used in functions.
RayCodeCSC is offline
thEsp
BANNED
Join Date: Aug 2017
Old 09-02-2019 , 14:47   Re: I need help with my plugin
Reply With Quote #8

Sorry but can you be more serious please? Read carefully what I said above.
thEsp is offline
RayCodeCSC
Junior Member
Join Date: Sep 2019
Old 09-02-2019 , 15:20   Re: I need help with my plugin
Reply With Quote #9

So I tried ExecuteHamB(), but it writes me the following errors:
Code:
test.sma(37) : error 029: invalid expression, assumed zero
test.sma(37) : warning 215: expression has no effect
test.sma(37) : error 001: expected token: ";", but found ")"
test.sma(37) : error 029: invalid expression, assumed zero
test.sma(37) : fatal error 107: too many error messages on one line
Specifically, I have the following:
Code:
ExecuteHamB(tkDamage1, victim)
script:
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init()
{
	register_plugin("Power Give", "1.0", "RayCodeCSC")
	register_clcmd("say /store", "store_menu")
	RegisterHam(Ham_TakeDamage, "player", "tkDamage1")
	RegisterHam(Ham_TakeDamage, "player", "tkDamage2")
}

public store_menu(id)
{
	new menu = menu_create("Choose from store:", "store_menu_selection")

	menu_additem(menu, "Power 1")
	menu_additem(menu, "Power 2")

	menu_display(id, menu)
}

public store_menu_selection(id, menu, item, victim)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}

	switch(item, victim)
	{
		case 0:
		{
			ExecuteHamB(tkDamage1, victim)
		}

		case 1:
		{
			ExecuteHamB(tkDamage2, victim)
		}
	}
}

public tkDamage1(victim, attacker, inflictor, Float:damage)
{
	if(get_user_flags(attacker) == ADMIN_LEVEL_A)
	{
		SetHamParamFloat(4, damage = 60.0)
	}
}

public tkDamage2(victim, attacker, inflictor, Float:damage)
{
	if(get_user_flags(attacker) == ADMIN_LEVEL_A)
	{
		SetHamParamFloat(4, damage = 120.0)
	}
}
RayCodeCSC is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 09-02-2019 , 15:34   Re: I need help with my plugin
Reply With Quote #10

You don't need ExecuteHamB, its used only when you want to apply a custom damage for new weapon / effect, you just want to edit the current weapon damage,

First you need to create a variable to hold player power level
and then based on that level change the damage in the forward

something like this :

PHP Code:
new g_PlayerPower[MAX_PLAYERS+1]

public 
tkDamage1(victimattackerinflictorFloat:damage)
{
    if(
g_PlayerPower[attacker] == 1)
    {
        
SetHamParamFloat(450.0)
    }
    else if(
g_PlayerPower[attacker] == 2)
    {
        
SetHamParamFloat(4100.0)
    }
    
// etc ....

__________________

Last edited by JusTGo; 09-02-2019 at 15:35.
JusTGo is offline
Reply


Thread Tools
Display Modes

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 22:24.


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