Raised This Month: $ Target: $400
 0% 

How to indexed array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
-B1ng0-
Member
Join Date: Nov 2009
Old 07-13-2010 , 13:44   How to indexed array
Reply With Quote #1

Hello guys, i make a test plugin for show my problem

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


public plugin_init() 
{ 
	register_plugin("test", "1.0", "-B1ng0-")
	
	register_concmd("amx_test", "test_command", ADMIN_KICK, "<name> <message>")
}

public test_command(id, level, cid)
{
	if(!cmd_access(id, level, cid, 3))
	{
		return PLUGIN_HANDLED
	}
	
	new target[24], message[64]
	read_argv(1, target, 23)
	read_argv(2, message, 63)
	
	
	new player = cmd_target(id, target, 9) 
	if (!player)
	{
		return PLUGIN_HANDLED
	}
	
	new array[2]
	array[0] = id
	array[1] = player
	
	set_task(1.0,"ssm_testexecute",message+3322,_,_,"a")
        
	return PLUGIN_HANDLED
}
 
public ssm_testexecute(array[2])
{
	new id = array[0]
	new player = array[1]   
	
	new name[32]
	get_user_name(id, name, 31) 
	    
	client_print(player, print_chat, "ADMIN %: %s", name, message)
	
	return PLUGIN_CONTINUE;
}
Error 033: array must be indexed (variable: message)
Here: set_task(1.0,"ssm_testexecute",message+3322,_ ,_,"a")


Help me solve this please
-B1ng0- is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 07-13-2010 , 14:05   Re: How to indexed array
Reply With Quote #2

Its id+3322
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-13-2010 , 14:06   Re: How to indexed array
Reply With Quote #3

You can't set a task with an entire array. What it wants you to do is:
PHP Code:
set_task(1.0"ssm_testexecute"message[0]+3322//If you only want the task to repeat once, there is no need for the "a" flag. 
So, I'd advise that you put the message in a global array, and use that. I actually don't think that what you want to do will work with a task *unless you create a global variable for one of the id's*. Try:
PHP Code:
#include <amxmodx>
#include <amxmisc>

new gMessage[64]

public 
plugin_init() 

    
register_plugin("test""1.0""-B1ng0-")
    
    
register_concmd("amx_test""test_command"ADMIN_KICK"<name> <message>")
}

public 
test_command(idlevelcid)
{
    if(!
cmd_access(idlevelcid3))
    {
        return 
PLUGIN_HANDLED
    
}
    
    new 
target[24]
    
read_argv(1target23)
    
read_argv(2gMessage63)
    
    
    new 
player cmd_target(idtarget9
    if (!
player)
    {
        return 
PLUGIN_HANDLED
    
}
    
    new array[
2]
    array[
0] = id
    
array[1] = player
    
    ssm_testexecute
(array)
        
    return 
PLUGIN_HANDLED
}
 
public 
ssm_testexecute(array[2])
{
    new 
id = array[0]
    new 
player = array[1]   
    
    new 
name[32]
    
get_user_name(idname31
        
    
client_print(playerprint_chat"ADMIN %: %s"namegMessage)
    
    return 
PLUGIN_CONTINUE;


Last edited by RedRobster; 07-13-2010 at 14:11.
RedRobster is offline
-B1ng0-
Member
Join Date: Nov 2009
Old 07-13-2010 , 14:20   Re: How to indexed array
Reply With Quote #4

I need to use message in next public and i need to use task because i need to repeat this public ssm_testexecute 3 times

set_task(1.0,"ssm_testexecute",0,array,2,"a", 3) like this but in public ssm_testexecute i need tu use message in clien_print ..
-B1ng0- is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-13-2010 , 14:41   Re: How to indexed array
Reply With Quote #5

Then I would advise creating a global variable: gPlayer and assigning the player variable to it. Then do:
PHP Code:
set_task(1.0"ssm_testexecute"id,_,_"a"3
RedRobster is offline
-B1ng0-
Member
Join Date: Nov 2009
Old 07-13-2010 , 15:04   Re: How to indexed array
Reply With Quote #6

dont work RedRoboster he show me my name but not my text

He show me this: ADMIN -B1ng0-: -B1ng0-
but i type this command amx_test -B1ng0- Test_message
need show me this: ADMIN -B1ng0-: Test_message

Last edited by -B1ng0-; 07-13-2010 at 15:06.
-B1ng0- is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-13-2010 , 15:12   Re: How to indexed array
Reply With Quote #7

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

new gMessage[64]
new 
gPlayer

public plugin_init() 

    
register_plugin("test""1.0""-B1ng0-")
    
    
register_concmd("amx_test""test_command"ADMIN_KICK"<name> <message>")
}

public 
test_command(idlevelcid)
{
    if(!
cmd_access(idlevelcid3))
    {
        return 
PLUGIN_HANDLED
    
}
    
    
gPlayer 0
    
    
new target[24]
    
read_argv(1target23)
    
read_argv(2gMessage63)
    
    
    
gPlayer cmd_target(idtarget9
    if (!
gPlayer)
    {
        return 
PLUGIN_HANDLED
    
}
    
    
set_task(1.0"ssm_testexecute"id,_,_,"a"3)
        
    return 
PLUGIN_HANDLED
}
 
public 
ssm_testexecute(id)
{
    new 
name[32]
    
get_user_name(idname31
        
    
client_print(gPlayerprint_chat"ADMIN %: %s"namegMessage)
    
    return 
PLUGIN_CONTINUE;

Try this.
RedRobster is offline
-B1ng0-
Member
Join Date: Nov 2009
Old 07-13-2010 , 15:21   Re: How to indexed array
Reply With Quote #8

@RedRobster THX YOU i found my problem

client_print(gPlayer, print_chat, "ADMIN %: %s", name, gMessage)

Here is it look at ADMIN % i forgot s = %s Thank You mate
-B1ng0- is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-13-2010 , 17:07   Re: How to indexed array
Reply With Quote #9

That could cause race conditions if amx_test is used by someone else (or the same person; different problem) before it has finished printing.

I believe you can send string through a set_task like:

Code:
set_task(time, "function", id+offset, string, sizeof(string), "a", 3)

public function(yourstring[])
{
    //  . . .
}
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-14-2010 , 09:02   Re: How to indexed array
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
That could cause race conditions if amx_test is used by someone else (or the same person; different problem) before it has finished printing.

I believe you can send string through a set_task like:

Code:
set_task(time, "function", id+offset, string, sizeof(string), "a", 3)

public function(yourstring[])
{
    //  . . .
}
You can pass an array and integer to the called function.

PHP Code:
new szText[] = "hi hello";
set_task1.0 "TheFunc" id szText sizeofszText ) , "a" );

public 
TheFuncarrData[] , id )
{
    
client_printid print_chat "Msg=%s" arrData );    

__________________
Bugsy 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 07:14.


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