AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help me with set_task? (https://forums.alliedmods.net/showthread.php?t=324684)

Arje 05-23-2020 14:58

Help me with set_task?
 
Hello !! well, I am using this plugin and it works correctly, but I would like the event of granting money after defuse to happen 1 or 2 seconds after I have defused,
I think this can be done with the set_task function but I don't know how to apply it.

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <csx>

static const PLUGIN_NAME[] = "Bomb Plant Money Bonus"
static const PLUGIN_VERSION[] = "1.0"
static const PLUGIN_AUTHOR[] = "Locks"

new PCvarBonus
new PCvarDefuseBonus

public plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
PCvarBonus register_cvar("amx_plant_bonus""150")
    
PCvarDefuseBonus register_cvar("amx_defuse_bonus""500")     // the defuse bonus could be changed 
}

public 
bomb_planted(id)
{
    new 
money cs_get_user_money(id)
    new 
bonus get_pcvar_num(PCvarBonus)
    
cs_set_user_money(idmoney bonus)
}

public 
bomb_defused(id)
{
    new 
money cs_get_user_money(id)
    new 
bonus get_pcvar_num(PCvarDefuseBonus)
    
cs_set_user_money(idmoney bonus)



Bugsy 05-23-2020 15:13

Re: Help me with set_task?
 
PHP Code:

//Put this in the bomb_defused() function
set_task1.0 "GiveMoney" id );

public 
client_disconnectid )
{
    
remove_taskid );
}

public 
GiveMoneyid )
{
    
cs_set_user_moneyid cs_get_user_moneyid ) + 2000 );



DJEarthQuake 05-23-2020 15:16

Re: Help me with set_task?
 
Quote:

Originally Posted by Arje (Post 2701851)
Hello !! well, I am using this plugin and it works correctly, but I would like the event of granting money after defuse to happen 1 or 2 seconds after I have defused,
I think this can be done with the set_task function but I don't know how to apply it.

https://www.amxmodx.org/api/amxmodx/set_task
Code:
public bomb_defused(id) {     set_task(random_float(1.0,2.0),"CT_bomb_reward", id) } public CT_bomb_reward(id) {     new money = cs_get_user_money(id)     new bonus = get_pcvar_num(PCvarDefuseBonus)     cs_set_user_money(id, money + bonus) }

Arje 05-23-2020 16:18

Re: Help me with set_task?
 
Quote:

Originally Posted by DJEarthQuake (Post 2701859)
https://www.amxmodx.org/api/amxmodx/set_task
Code:
public bomb_defused(id) {     set_task(random_float(1.0,2.0),"CT_bomb_reward", id) } public CT_bomb_reward(id) {     new money = cs_get_user_money(id)     new bonus = get_pcvar_num(PCvarDefuseBonus)     cs_set_user_money(id, money + bonus) }


thanks to both of them both work properly, and thanks for showing me how to use the set_task!

OciXCrom 05-23-2020 16:18

Re: Help me with set_task?
 
Quote:

Originally Posted by DJEarthQuake (Post 2701859)
Code:
set_task(random_float(1.0,2.0),"CT_bomb_reward", id)

I think you understood the question way too literally. :?

Bugsy 05-23-2020 16:19

Re: Help me with set_task?
 
This?

random_float(1.0,2.0)

Yeah I thought the same lol


All times are GMT -4. The time now is 17:09.

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