AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   using public death() (https://forums.alliedmods.net/showthread.php?t=17457)

MichielM 09-01-2005 14:31

using public death()
 
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 09-01-2005 16:10

please someone respond not only read :? tnx

W33ck4 09-01-2005 16:16

Death event
 
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

Zenith77 09-01-2005 16:25

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!" )

MichielM 09-01-2005 16:27

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
}


Zenith77 09-01-2005 16:30

you dont have to make a new function... Replace Myfunc with drop_user_money or w/e it is ;)

MichielM 09-01-2005 16:44

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)

W33ck4 09-01-2005 16:55

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 :)

MichielM 09-01-2005 16:58

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?

W33ck4 09-01-2005 17:00

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.


All times are GMT -4. The time now is 14:21.

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