Raised This Month: $ Target: $400
 0% 

set_task help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jingojang
Senior Member
Join Date: Feb 2010
Location: The Moon
Old 03-24-2013 , 14:07   set_task help
Reply With Quote #1

Just wondering about the set_task, can someone show me how to type it out?
I was reading about the task_remove and task_exists but not sure where to put it.

And when I use this with exolents hidenseek plugin the weapons just gets stripped in the beginning of the round.

PHP Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <colorchat>
#include <cstrike>

#define VERSION "1.0"

new pcvar_toggleweaponchance

public plugin_init() {
    
register_plugin("Weapon Chance"VERSION"Napoleon")
    
RegisterHam(Ham_Spawn"player""fw_weapon_chance"1)
    
set_task 10.0"fw_weapon_chance"123 )
    
    
pcvar_toggleweaponchance register_cvar("amx_toggleweaponchance""1")
}

public 
fw_weapon_chance(id

{
    if(!
get_pcvar_num(pcvar_toggleweaponchance)) {
        return 
PLUGIN_HANDLED
    
}
    new 
iNum random_num(0100)
    
    if(
iNum >= 99) {
        
cs_set_weapon_ammo(give_item(id"weapon_awp"), 2)
        
ColorChat(idGREY"^x04[NG]^x03 You received an^x04 AWP^x03 with^x04 2 Bullets^x03 (1%%) ^x04Watch out!")
    }
    if(
iNum >= 95) {
        
cs_set_weapon_ammo(give_item(id"weapon_deagle"), 1)
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 Deagle^x03 with^x04 1 Bullet^x03 (5%%)")
    }
    if(
iNum >= 80) {
        
give_item(id"weapon_hegrenade")
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 High Explosive^x03 (20%%)")
    }
    if(
iNum >= 95) {
        
cs_set_weapon_ammo(give_item(id"weapon_fiveseven"), 2)
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 Fiveseven^x03 with^x04 2 Bullets^x03 (5%%)")
    }
    if(
iNum >= 90) {
        
set_user_armor(id100)
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 100 armor^x03 (10%%)")
    }
    if(
iNum >= 95) {
        
set_user_health(id150)
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 150 Health^x03 (5%%)")
    }
    return 
PLUGIN_CONTINUE
    
}


Last edited by jingojang; 03-24-2013 at 14:30.
jingojang is offline
raresnr1
Member
Join Date: Apr 2012
Old 03-24-2013 , 14:33   Re: set_task help
Reply With Quote #2

i dont know is good,but ...
PHP Code:
#include <amxmodx> 
#include <fun> 
#include <hamsandwich> 
#include <colorchat> 
#include <cstrike> 

#define VERSION "1.0" 

new pcvar_toggleweaponchance 

enum
{
weapon
}

public 
plugin_init() { 
register_plugin("Weapon Chance"VERSION"Napoleon"
RegisterHam(Ham_Spawn"player""fw_weapon_chance"1
set_task10"fw_weapon_change"weapon__"a"123 ); 

pcvar_toggleweaponchance register_cvar("amx_toggleweaponchance""1"


public 
fw_weapon_chance(id)  


if(!
get_pcvar_num(pcvar_toggleweaponchance)) { 
    return 
PLUGIN_HANDLED 

new 
iNum random_num(0100

if(
iNum >= 99) { 
    
cs_set_weapon_ammo(give_item(id"weapon_awp"), 2
    
ColorChat(idGREY"^x04[NG]^x03 You received an^x04 AWP^x03 with^x04 2 Bullets^x03 (1%%) ^x04Watch out!"

if(
iNum >= 95) { 
    
cs_set_weapon_ammo(give_item(id"weapon_deagle"), 1
    
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 Deagle^x03 with^x04 1 Bullet^x03 (5%%)"

if(
iNum >= 80) { 
    
give_item(id"weapon_hegrenade"
    
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 High Explosive^x03 (20%%)"

if(
iNum >= 95) { 
    
cs_set_weapon_ammo(give_item(id"weapon_fiveseven"), 2
    
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 Fiveseven^x03 with^x04 2 Bullets^x03 (5%%)"

if(
iNum >= 90) { 
    
set_user_armor(id100
    
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 100 armor^x03 (10%%)"

if(
iNum >= 95) { 
    
set_user_health(id150
    
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 150 Health^x03 (5%%)"

if( 
task_existsweapon ) )
    
remove_taskweapon );    
    return 
PLUGIN_CONTINUE 


Last edited by raresnr1; 03-24-2013 at 14:34.
raresnr1 is offline
jingojang
Senior Member
Join Date: Feb 2010
Location: The Moon
Old 03-24-2013 , 15:04   Re: set_task help
Reply With Quote #3

Did you try to compile it?

PHP Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// WeaponChance2.sma
// C:\Users\Lirran\Desktop\Server Relaterat\Compiler #2\WeaponChance2.sma(19) :
warning 213tag mismatch
// C:\Users\Lirran\Desktop\Server Relaterat\Compiler #2\WeaponChance2.sma(58) :
warning 217loose indentation
// Header size:            872 bytes
// Code size:             3620 bytes
// Data size:             2076 bytes
// Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
// Total requirements:   22952 bytes
//
// 2 Warnings.
// Done.
//
// Compilation Time: 0,27 sec
// ----------------------------------------

Press enter to exit ... 

Last edited by jingojang; 03-24-2013 at 15:50.
jingojang is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-24-2013 , 17:23   Re: set_task help
Reply With Quote #4

Quote:
Originally Posted by jingojang View Post
Just wondering about the set_task, can someone show me how to type it out?
I was reading about the task_remove and task_exists but not sure where to put it.

And when I use this with exolents hidenseek plugin the weapons just gets stripped in the beginning of the round.
Since you are asking about Scripting Help, you should post in the Scripting Help section (maybe a moderator will move it).

What are you trying to do? Your use of set_task() is not incorrect, technically speaking.
__________________
fysiks is offline
Old 03-24-2013, 17:23
Jhob94
This message has been deleted by Jhob94. Reason: fysiks posted same thing at same time
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 03-24-2013 , 18:15   Re: set_task help
Reply With Quote #5

Rather than doing it the way you do it now, you should hook round start and set a task for a few seconds (so the weapons given don't get stripped immediately). If you'd like it to run again later just make sure it's the same round (hook round end and use a boolean or something similar).

@raresnr1: If you're unsure about it then don't bother posting. Your code is horribly wrong.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
jingojang
Senior Member
Join Date: Feb 2010
Location: The Moon
Old 03-25-2013 , 03:49   Re: set_task help
Reply With Quote #6

Quote:
Originally Posted by DarkGod View Post
Rather than doing it the way you do it now, you should hook round start and set a task for a few seconds (so the weapons given don't get stripped immediately). If you'd like it to run again later just make sure it's the same round (hook round end and use a boolean or something similar).

@raresnr1: If you're unsure about it then don't bother posting. Your code is horribly wrong.
I can do the register_logevent but it still does not work with hidenseek by exolent for some reason. Does not matter where I put it in plugins.ini either. That's why I wanted someone to show me how to use task_remove and task_exists.

@fysiks Sorry for posting in the wrong section, mod please move the thread if needed. I'm trying set a task that gives the player the weaponchance after 10.0 sec.

Last edited by jingojang; 03-25-2013 at 03:53.
jingojang is offline
Erdener
Senior Member
Join Date: Apr 2010
Location: Turkey
Old 03-25-2013 , 04:30   Re: set_task help
Reply With Quote #7

PHP Code:
#include <amxmodx> 
#include <fun> 
#include <hamsandwich> 
#include <colorchat> 
#include <cstrike> 

#define VERSION "1.0" 

new pcvar_toggleweaponchance 

enum
{
    
weapon
}

public 
plugin_init() { 
    
register_plugin("Weapon Chance"VERSION"Napoleon"
    
RegisterHam(Ham_Spawn"player""fw_weapon_chance"1
    
set_task(1.0"fw_weapon_change"weapon__"a"123 ); 

    
pcvar_toggleweaponchance register_cvar("amx_toggleweaponchance""1"


public 
fw_weapon_chance(id)  

    if(!
get_pcvar_num(pcvar_toggleweaponchance)) { 
            return 
PLUGIN_HANDLED 
    
}
    new 
iNum random_num(0100

    if(
iNum >= 99) { 
        
cs_set_weapon_ammo(give_item(id"weapon_awp"), 2
        
ColorChat(idGREY"^x04[NG]^x03 You received an^x04 AWP^x03 with^x04 2 Bullets^x03 (1%%) ^x04Watch out!"
    } 
    if(
iNum >= 95) { 
        
cs_set_weapon_ammo(give_item(id"weapon_deagle"), 1
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 Deagle^x03 with^x04 1 Bullet^x03 (5%%)"
    } 
    if(
iNum >= 80) { 
        
give_item(id"weapon_hegrenade"
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 High Explosive^x03 (20%%)"
    } 
    if(
iNum >= 95) { 
        
cs_set_weapon_ammo(give_item(id"weapon_fiveseven"), 2
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 Fiveseven^x03 with^x04 2 Bullets^x03 (5%%)"
    } 
    if(
iNum >= 90) { 
        
set_user_armor(id100
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 100 armor^x03 (10%%)"
    } 
    if(
iNum >= 95) { 
        
set_user_health(id150
        
ColorChat(idGREY"^x04[NG]^x03 You received a^x04 150 Health^x03 (5%%)"
    } 
    if( 
task_existsweapon ) )
    
remove_taskweapon );    
    return 
PLUGIN_CONTINUE 

Erdener is offline
jingojang
Senior Member
Join Date: Feb 2010
Location: The Moon
Old 03-25-2013 , 12:43   Re: set_task help
Reply With Quote #8

Thanks Erdener, I just have one question as I said in my first post.

Why is this not working with hidenseek by Exolent? Can someone get him to comment here please!

Last edited by jingojang; 03-26-2013 at 12:33.
jingojang is offline
Larcyn
Senior Member
Join Date: Oct 2010
Old 03-27-2013 , 13:13   Re: set_task help
Reply With Quote #9

Put the compiled file on the top of your plugins.ini and restart your server.
__________________

Taking private requests, PM me for information.
Selling HideNSeek & Jailbreak plugins.

Selling Achievement API System (PHP &
MySQL / nVault)
Larcyn is offline
jingojang
Senior Member
Join Date: Feb 2010
Location: The Moon
Old 03-28-2013 , 15:52   Re: set_task help
Reply With Quote #10

No luck, can someone get Exolent to comment here please!
jingojang is offline
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 00:09.


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