Raised This Month: $ Target: $400
 0% 

Problem with passing an array by set_task


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[PUPPETS] Scooter
Member
Join Date: May 2009
Old 12-25-2009 , 14:52   Problem with passing an array by set_task
Reply With Quote #1

Hello,
I've got a problem with passing a Steam-ID from one function to another one by set_task. Here's my code:

Code:
public check_manual(id, level, cid)
{
 ...
 new header_connect[4]
 
 header_connect[0] = id 
 format(header_connect[1], 31 ,"%s", player_steam)
 // Point1
 console_print(id, header_connect[1]) 
 header_connect[2] = player_exists 
 header_connect[3] = player_id 
 
 set_task(1.0, "connect_web", id, header_connect, 4)
 ...
}
 
public connect_web(arg[])
{
... 
 //Point2
 console_print(id,arg[1])
...
}
At Point1 I get (as it should be):
STEAM_0:0:1234

But in connect_web at Point2, it's reduced to:
S_M

If I replace 4 in set_task by 80, I get:
S_MAM_0:0:1234

Why do I get S_MAM.. instead of STEAM and why do I have to increase array size in set_task?

Thanks for your help,
Scooter
[PUPPETS] Scooter is offline
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 12-25-2009 , 18:23   Re: Problem with passing an array by set_task
Reply With Quote #2

http://forums.alliedmods.net/showpos...5&postcount=11
Yeah, increase it so it can contain all your data in a long string.
Does player_id contain the full steamid?
__________________
ehha is offline
[PUPPETS] Scooter
Member
Join Date: May 2009
Old 12-26-2009 , 07:44   Re: Problem with passing an array by set_task
Reply With Quote #3

Thank you for the link. After putting everything in one array, it works fine.

That's my new code:
Code:
new header_connect[80] 
 header_connect[0] = id //id of admin
 header_connect[1] = player_exists //victim on server?
 header_connect[10] = player_id //id of victim
 format(header_connect[20], 31 ,"%s", player_steam) //victim's steam-id
id and player_id are integers, player_exists is bool and player_steam contains one steam-id.
[PUPPETS] Scooter is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-26-2009 , 08:33   Re: Problem with passing an array by set_task
Reply With Quote #4

Quote:
Originally Posted by [PUPPETS] Scooter View Post
Thank you for the link. After putting everything in one array, it works fine.

That's my new code:
Code:
new header_connect[80] 
 header_connect[0] = id //id of admin
 header_connect[1] = player_exists //victim on server?
 header_connect[10] = player_id //id of victim
 format(header_connect[20], 31 ,"%s", player_steam) //victim's steam-id
id and player_id are integers, player_exists is bool and player_steam contains one steam-id.
Here's a more organized\readable way to do this:
PHP Code:
enum _:ConnectHeader
{
    
iPlayerID,
    
bool:bPlayerExists,
    
iVictimID
    
szSteamID35 ]
}

public 
client_putinserverid )
{
    new 
chDataConnectHeader ];

    
chDataiPlayerID ] = id;
    
chDatabPlayerExists ] = true;
    
chDataiVictimID ] = -1;
    
get_user_authidid chDataszSteamID ] , 34 );

    
set_task7.0 "ShowData" id chData sizeofchData ) );
}

public 
ShowDatachData[] , id )
{
    
client_printid print_chat "iPlayerID=%d bPlayerExists=%d iVictimID=%d szSteamID=%s" chDataiPlayerID ] , chDatabPlayerExists ] , chDataiVictimID ] , chDataszSteamID ] );

__________________
Bugsy is offline
[PUPPETS] Scooter
Member
Join Date: May 2009
Old 01-06-2010 , 10:21   Re: Problem with passing an array by set_task
Reply With Quote #5

I finally had time to test your version, it also works great and is easier to handle. Thanks.
[PUPPETS] Scooter is offline
ÜnLoCo
Member
Join Date: Dec 2009
Location: 35.77N, 10.82E
Old 06-01-2010 , 23:34   Re: Problem with passing an array by set_task
Reply With Quote #6

this is useful thank you guys !!!!
i had to say it !
__________________
ÜnLoCo 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 04:17.


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