Raised This Month: $ Target: $400
 0% 

using public death()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MichielM
Member
Join Date: Aug 2005
Old 09-01-2005 , 14:31   using public death()
Reply With Quote #1

ok this is what i need to know.. i got a script(part of economymod) that drops an amount of money when i say /drop ... (it creates a model on the orgin and someone can pick it up)

now i want also when someone dies, his cash drops to. i tried a few things but nothing seems to work.

i tought it would something like ?
Code:
public death() user_drop_money(id,amount)
this is where i must get the amount (wallet)
Code:
format(query,255,"SELECT wallet FROM money WHERE steamid='%s'",authid)
		dbi_query(dbc,query)
a part of the /drop code

Code:
if(equali(buffer1,"/drop"))
	{
		user_drop_money(id,str_to_num(buffer2))
		return PLUGIN_HANDLED
	}

can someone please help me
MichielM is offline
MichielM
Member
Join Date: Aug 2005
Old 09-01-2005 , 16:10  
Reply With Quote #2

please someone respond not only read tnx
MichielM is offline
W33ck4
Junior Member
Join Date: Sep 2005
Location: Lithuania
Old 09-01-2005 , 16:16   Death event
Reply With Quote #3

How to start your function when someone dies you can see here:
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> public plugin_init() {     register_plugin("DeathPlugin", "0.01", "W33ck4")     register_event("DeathMsg", "EventDeath", "b") } public EventDeath(id) {     new victim = read_data(2)             user_drop_money(victim)     client_print(victim, print_chat, "Your money is on the ground")       return PLUGIN_HANDLED }

How you see, I left you to write user_drop_money function
That function should also get wallet info from SQL database
W33ck4 is offline
Send a message via Yahoo to W33ck4
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-01-2005 , 16:25  
Reply With Quote #4

and you realy dont need the
Code:
if(equali(buffer1,"/drop"))
remove the if statement...the code will only acitvate if they say the command.


If it is not registered already add this ( where it says MyFunc put the the function that corresponds with your code )

Code:
register_clcmd( "say /drop", "Myfun", ADMIN_ALL, "Drops your wallet!" )
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
MichielM
Member
Join Date: Aug 2005
Old 09-01-2005 , 16:27  
Reply With Quote #5

ok tnx for the respond.. the main problem is the function already exists (and is used by the /drop), and ofcouse want to use it insteadof copy it to a new function (to save bytes)
ok so if this is the function, how should i fix it?

Code:
public user_drop_money(id,amount)
{
	if(!is_user_alive(id)) return PLUGIN_HANDLED
	if(is_user_database(id) == 0) {
		print_text(id)
		return PLUGIN_HANDLED
	}
	if(amount <= 0) {
		client_print(id,print_chat,"[EconomyMod] Usage:  /drop <name> <amount>^n")
		return PLUGIN_HANDLED
	}

	new origin[3], authid[32], query[256], wallet, Float:forigin[3]
	get_user_origin(id,origin)
	get_user_authid(id,authid,31)

	format(query,255,"SELECT wallet FROM money WHERE steamid='%s'",authid)
	result = dbi_query( dbc, query)
	if( dbi_nextrow( result ) <= 0 ) {
		dbi_free_result(result)
		return PLUGIN_HANDLED
	}
	wallet = dbi_field(result,1)
	dbi_free_result(result)
	if(amount > wallet) {
		client_print(id,print_chat,"[EconomyMod] You don't have enough money in your wallet!")
		return PLUGIN_HANDLED
	}

	new ent = create_entity("info_target")
	if(!ent) return PLUGIN_HANDLED

	IVecFVec(origin,forigin)

	new Float:minbox[3] = { -2.5, -2.5, -2.5 }
	new Float:maxbox[3] = { 2.5, 2.5, -2.5 }
	new Float:angles[3] = { 0.0, 0.0, 0.0 }

	angles[1] = float(random_num(0,270))

	entity_set_vector(ent,EV_VEC_mins,minbox)
	entity_set_vector(ent,EV_VEC_maxs,maxbox)
	entity_set_vector(ent,EV_VEC_angles,angles)



	entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER)
	entity_set_int(ent,EV_INT_movetype,MOVETYPE_TOSS)

	
	new moneystr[32]
	num_to_str(amount,moneystr,31)
	entity_set_string(ent,EV_SZ_targetname,moneystr)
	entity_set_string(ent,EV_SZ_classname,"money_pile")

	entity_set_model(ent,"models/hwrp/money.mdl")
	entity_set_origin(ent,forigin)

	g_delay_ent[id] = 2
	edit_value(id,"money","wallet","-",amount)
	client_print(id,print_chat,"[EconomyMod] You dropped $%i on the ground",amount)
	return PLUGIN_HANDLED
}
MichielM is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-01-2005 , 16:30  
Reply With Quote #6

you dont have to make a new function... Replace Myfunc with drop_user_money or w/e it is ;)
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
MichielM
Member
Join Date: Aug 2005
Old 09-01-2005 , 16:44  
Reply With Quote #7

eehm u mean change it on this?>
Code:
register_clcmd( "say /drop", "Myfun", ADMIN_ALL, "Drops your wallet!" )
than it also wont solve my problem..

let me say it on a diffrent way..
i want to set this function
Code:
user_drop_money(id,amount)
when someone dies. it must get the amount from a mysql table (table name money, line wallet)
MichielM is offline
W33ck4
Junior Member
Join Date: Sep 2005
Location: Lithuania
Old 09-01-2005 , 16:55  
Reply With Quote #8

Quote:
Originally Posted by MichielM
eehm u mean change it on this?>
Code:
register_clcmd( "say /drop", "Myfun", ADMIN_ALL, "Drops your wallet!" )
than it also wont solve my problem..

let me say it on a diffrent way..
i want to set this function
Code:
user_drop_money(id,amount)
when someone dies. it must get the amount from a mysql table (table name money, line wallet)
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("DeathPlugin", "0.01", "W33ck4")     register_event("DeathMsg", "EventDeath", "b") } public EventDeath(id) {     new victim = read_data(2)             user_drop_money(victim)     return PLUGIN_HANDLED } public user_drop_money(id) {    new origin[3], authid[32], query[256], wallet, Float:forigin[3]    get_user_origin(id,origin)    get_user_authid(id,authid,31)    format(query,255,"SELECT wallet FROM money")    result = dbi_query( dbc, query)    if( dbi_nextrow( result ) <= 0 ) {       dbi_free_result(result)       return PLUGIN_HANDLED    }    wallet = dbi_field(result,1)    dbi_free_result(result)    new amount = wallet    new ent = create_entity("info_target")    if(!ent) return PLUGIN_HANDLED    IVecFVec(origin,forigin)    new Float:minbox[3] = { -2.5, -2.5, -2.5 }    new Float:maxbox[3] = { 2.5, 2.5, -2.5 }    new Float:angles[3] = { 0.0, 0.0, 0.0 }    angles[1] = float(random_num(0,270))    entity_set_vector(ent,EV_VEC_mins,minbox)    entity_set_vector(ent,EV_VEC_maxs,maxbox)    entity_set_vector(ent,EV_VEC_angles,angles)    entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER)    entity_set_int(ent,EV_INT_movetype,MOVETYPE_TOSS)        new moneystr[32]    num_to_str(amount,moneystr,31)    entity_set_string(ent,EV_SZ_targetname,moneystr)    entity_set_string(ent,EV_SZ_classname,"money_pile")    entity_set_model(ent,"models/hwrp/money.mdl")    entity_set_origin(ent,forigin)    g_delay_ent[id] = 2    edit_value(id,"money","wallet","-",amount)    client_print(id,print_chat,"[EconomyMod] You dropped $%i on the ground",amount)    return PLUGIN_HANDLED }
I think this should work... And I guess it would be more intresting, that money amount would be equal to money which player had before death. Also, that dead player's money could be set to 0 That's just a suggestion
W33ck4 is offline
Send a message via Yahoo to W33ck4
MichielM
Member
Join Date: Aug 2005
Old 09-01-2005 , 16:58  
Reply With Quote #9

ok, i'll try something like that.. but would u like to explain were "read_data(2) " stands for?
that should be related with wallet?
MichielM is offline
W33ck4
Junior Member
Join Date: Sep 2005
Location: Lithuania
Old 09-01-2005 , 17:00  
Reply With Quote #10

Quote:
Originally Posted by MichielM
ok, i'll try something like that.. but would u like to explain were "read_data(2) " stands for?
that should be related with wallet?
No it should not. It reads the seccond parameter of DeathEvent. The first one is attacker, seccond - victim, and the third is weapon.
W33ck4 is offline
Send a message via Yahoo to W33ck4
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 14:21.


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