Raised This Month: $51 Target: $400
 12% 

Syntax info needed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CodeMaster
Junior Member
Join Date: Dec 2008
Old 12-26-2008 , 11:14   Syntax info needed
Reply With Quote #1

My code is getting bigger and bigger as time passes, so I'm interested onto how to shorten it.

Thing I'm interested into is can the array needed by timer be replaced with:

set_task(0.5,"check_something",0,{id},1,"b")

Also what is used to get auto id for a timer? For example that way I wouldn't think what's timers id are used, if its not-for-killing timer.

Could this work?
set_task(0.5,"check_something",-1,{id},1,"b")

Thanks

Nidza
__________________
+karma me if you found me useful
[60% -- ||||||||||] Learning AMXModX functions for better adaption to AMXModX Pawn
[100% - ||||||||||] Pawn Readaptation

CodeMaster is offline
L//
Senior Member
Join Date: Aug 2008
Location: Not found
Old 12-26-2008 , 12:04   Re: Syntax info needed
Reply With Quote #2

example of how to get the id of the task and how to kill a task


PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Set task"
#define VERSION "1.0"
#define AUTHOR "L//"

#define TASK_TIMER    2000

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say test""test")
    
register_clcmd("say block""block_task")
}

public 
test(id)
{
    new 
param[1]
    
param[0] = id 
    set_task
(2.0"send_say"TASK_TIMERparam1)
    
client_print(idprint_chat"Say sent")

    return 
PLUGIN_HANDLED
}

public 
block_task()
{
    
remove_task(TASK_TIMER)
    
client_print(0print_chat"Say blocked")
    
    return 
PLUGIN_HANDLED
}

public 
send_say(param[])

    new 
id param[0]
    
    
client_print(idprint_chat"Say received")

L// is offline
Send a message via MSN to L//
CodeMaster
Junior Member
Join Date: Dec 2008
Old 12-26-2008 , 15:10   Re: Syntax info needed
Reply With Quote #3

Dude all that I knew from before -.-
All that I asked was can I get first free id (I use multiple tasks), and can I send params directly without making an array...

Anyone else?
__________________
+karma me if you found me useful
[60% -- ||||||||||] Learning AMXModX functions for better adaption to AMXModX Pawn
[100% - ||||||||||] Pawn Readaptation

CodeMaster is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 12-26-2008 , 20:14   Re: Syntax info needed
Reply With Quote #4

Quote:
Originally Posted by CodeMaster View Post
Dude all that I knew from before -.-
All that I asked was can I get first free id (I use multiple tasks), and can I send params directly without making an array...

Anyone else?
The usual way is to use defines for the multiple tasks and add/subtract them from the player ID.

E.g:
Code:
#define TASK1_ID 1000

whatever(id)
{
    set_task(1.0, "Task1", id + TASK1_ID)
}
public Task1(id)
{
    id -= TASK1_ID
    
    // blah
}
__________________

Community / No support through PM
danielkza is offline
CodeMaster
Junior Member
Join Date: Dec 2008
Old 12-27-2008 , 07:34   Re: Syntax info needed
Reply With Quote #5

Thanks, and what about sending params faster? {id}

Nidza
__________________
+karma me if you found me useful
[60% -- ||||||||||] Learning AMXModX functions for better adaption to AMXModX Pawn
[100% - ||||||||||] Pawn Readaptation

CodeMaster is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 12-27-2008 , 07:42   Re: Syntax info needed
Reply With Quote #6

afaik sending the params in the set_task (like L// showed) is the fastest way but you could also create global vars for storing the data.
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 12-27-2008 , 11:57   Re: Syntax info needed
Reply With Quote #7

As for your question of "can you use {variable} to create an array?", it would have been a lot quicker for you to test it and find out.

If you're not going to call change_task(), remove_task() or task_exists() and you're only sending one integer inside an array, you can leave the array empty and use the task ID to pass that integer. It doesn't matter if task IDs collide.

PHP Code:
public client_connect(id)
{
    
set_task(0.5"myTask"id__"b");
}

public 
myTask(id)
{
    
server_cmd("kick #%i"get_user_userid(id));

__________________
No support via PM.

Last edited by Lee; 12-27-2008 at 17:32.
Lee is offline
CodeMaster
Junior Member
Join Date: Dec 2008
Old 12-27-2008 , 17:15   Re: Syntax info needed
Reply With Quote #8

Well I've actually tested it, and it didn't work, so I wanted to ask did I had a well placed idea and something could be worked out, or it was truly wrong.

IDs can intercept without causing any problems?
Thanks for the tip.

Nidza
__________________
+karma me if you found me useful
[60% -- ||||||||||] Learning AMXModX functions for better adaption to AMXModX Pawn
[100% - ||||||||||] Pawn Readaptation

CodeMaster 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 10:02.


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