Raised This Month: $12 Target: $400
 3% 

Solved Storing user ID's


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 09-03-2017 , 13:30   Storing user ID's
Reply With Quote #1

I'm working on a plugin that would allow the user to buy healing bullets which would return 60% of the damage done to your enemy as health.

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "Healing Bullets"
#define AUTHOR "Dracula Mafioso"
#define VERSION "1.0"
new purchased
new attackerid
new savedattackerid
new damage
new health
new weapon
new clip
new ammocount
public plugin_init()
{
	register_plugin(PLUGIN,VERSION,AUTHOR);
	register_event("Damage", "takedamage","b", "2>1");
	register_clcmd("+attack", "reducebullets", 0);
	register_clcmd("healingbullets", "CmdBuy", 0, "Buys healing bullets");
}
public CmdBuy(id)
{
	weapon = get_user_weapon(id, clip, _);
	switch(weapon)
	{
		case CSW_USP:
		{
			if(purchased == 0)
			{
				client_print(id, print_center, "You already have purchased it!");
				return PLUGIN_HANDLED
			}
			cs_set_weapon_ammo(weapon, 12);
			client_print(id, print_center, "You have purchased 1 clip of healing bullets");
			ammocount = 12;
		}
	}
}
public reducebullets(attackerid)
{
	if(purchased == 0)
	{
		return PLUGIN_HANDLED
	}
	if(ammocount == 0)
	{
		purchased = 0;
		return PLUGIN_HANDLED;
	}
	ammocount--
	savedattackerid = attackerid
}
public takedamage(id)
{
	damage = read_data(2)
	if(damage <= 4)
	{
		return PLUGIN_HANDLED;
	}
	health = get_user_health(savedattackerid);
	set_user_health(savedattackerid, 50);
	client_print(0, print_chat, "Attacker hp: %d", health);
}
Ignore the fact that it's mostly incomplete with most important checks omitted from it, I can't progress on everything else when I can't store the attacker's/ the person who purchased the upgrade ID.

I need to store the person who bought the upgrade's ID so I can make a distinction when setting his health in the takedamage() function.
When I run it and do damage, it displays this:


From what I can tell it's either:
1. Not fetching the ID or
2. Not storing the ID properly


set_user_health is there is to test if the ID is being saved and the client_print is there too for debugging purposes.
What to do?

Last edited by Reel mafioso; 09-04-2017 at 15:04. Reason: Solved issue
Reel mafioso is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-03-2017 , 14:06   Re: Storing user ID's
Reply With Quote #2

PHP Code:
public takedamage(victim)
{
    
damage read_data(2)
    if(
damage <= 4)
    {
        return 
PLUGIN_HANDLED;
    }
    if(( 
attackerid get_user_attacker(victim))) { 
         
set_user_health(attackerid50);
        
health get_user_health(attackerid);
        }
    
client_print(0print_chat"Attacker hp: %d"health);


I honestly dont know what you are trying to achieve.
__________________
@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-03-2017 at 14:17.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 09-03-2017 , 14:13   Re: Storing user ID's
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
PHP Code:
public takedamage(id)
{
        new 
victim read_data(1)// im not sure about this... If its 1st data num or what..
    
damage read_data(2)
    if(
damage <= 4)
    {
        return 
PLUGIN_HANDLED;
    }
    
health get_user_health(savedattackerid);
    if(( 
attackerid get_user_attacker(victim)))  set_user_health(attackerid50);
    
client_print(0print_chat"Attacker hp: %d"health);


I honestly dont know what you are trying to achieve.
Is it not written well enough? I said I want to store the attacker's id.
Now I see that get_user_attacker function exists which is exactly what I need. Btw not sure about read_data(1) because afaik it's for "DamageSave" (not sure how that reads the victims id)
Reel mafioso is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-03-2017 , 16:03   Re: Storing user ID's
Reply With Quote #4

Read the edit

The victim id is passed in the first parameter
__________________
@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-03-2017 at 16:04.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 09-04-2017 , 15:03   Re: Storing user ID's
Reply With Quote #5

Well I fixed it by using get_attacker_id function. Thanks for the input anyway.
Reel mafioso 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 04:21.


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