Raised This Month: $23 Target: $400
 5% 

Help me with set_task?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arje
Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 05-23-2020 , 14:58   Help me with set_task?
Reply With Quote #1

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)


Last edited by Arje; 05-23-2020 at 15:01.
Arje is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-23-2020 , 15:13   Re: Help me with set_task?
Reply With Quote #2

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

__________________

Last edited by Bugsy; 05-23-2020 at 15:13.
Bugsy is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 05-23-2020 , 15:16   Re: Help me with set_task?
Reply With Quote #3

Quote:
Originally Posted by Arje View Post
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) }
__________________
"It's not the actual programming that's interesting. But it's what you can accomplish with the end results that are important." -Dennis Ritchie
"Mathematics, rightly viewed, possesses not only truth, but supreme beauty — a beauty cold and austere, like that of sculpture..." -Bertrand Russell

Last edited by DJEarthQuake; 05-23-2020 at 15:24. Reason: Did the opposite. My bad Bugsy no response when I began.
DJEarthQuake is offline
Arje
Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 05-23-2020 , 16:18   Re: Help me with set_task?
Reply With Quote #4

Quote:
Originally Posted by DJEarthQuake View Post
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!
Arje is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-23-2020 , 16:18   Re: Help me with set_task?
Reply With Quote #5

Quote:
Originally Posted by DJEarthQuake View Post
Code:
set_task(random_float(1.0,2.0),"CT_bomb_reward", id)
I think you understood the question way too literally.
__________________

Last edited by OciXCrom; 05-23-2020 at 16:21.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-23-2020 , 16:19   Re: Help me with set_task?
Reply With Quote #6

This?

random_float(1.0,2.0)

Yeah I thought the same lol
__________________
Bugsy 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 13:25.


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