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

Problem with DataPacks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-03-2015 , 22:05   Problem with DataPacks
Reply With Quote #1

PHP Code:
public MenuHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select)
    {
        new 
Handle:data CreateDataPack();
        
WritePackCell(dataparam1);
        
SQL_TQuery(dbCheckDB "some query"data);
    }
}

public 
CheckDB (Handle:ownerHandle:hndl, const String:error[], any:data)
{
    new 
client ReadPackCell(data);
    
PrintToChat(data"test");


Code:
[SM] Native "PrintToChat" reported: Client index 431227078 is invalid
Why? How to fix?

crap nvm i was using wrong variable

Last edited by 8guawong; 03-03-2015 at 22:11.
8guawong is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 03-03-2015 , 22:19   Re: Problem with DataPacks
Reply With Quote #2

you forgot to reset the pack. Also your passing a handle to a native expecting client index, I'm assuming you meant to use the variable client instead of data.
__________________

Last edited by WildCard65; 03-03-2015 at 22:20.
WildCard65 is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 03-04-2015 , 00:45   Re: Problem with DataPacks
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
PHP Code:
public MenuHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select)
    {
        new 
Handle:data CreateDataPack();
        
WritePackCell(dataparam1);
        
SQL_TQuery(dbCheckDB "some query"data);
    }
}

public 
CheckDB (Handle:ownerHandle:hndl, const String:error[], any:data)
{
    new 
client ReadPackCell(data);
    
PrintToChat(data"test");


Code:
[SM] Native "PrintToChat" reported: Client index 431227078 is invalid
Why? How to fix?

crap nvm i was using wrong variable
Here's how to fix that issue:
Code:
public MenuHandler(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select)
	{
		new Handle:data = CreateDataPack();
		WritePackCell(data, GetClientUserId(param1));
		SQL_TQuery(db, CheckDB "some query", data);
	}
}

public CheckDB (Handle:owner, Handle:hndl, const String:error[], any:data)
{
	ResetPack(data);
	new client = GetClientOfUserId(ReadPackCell(data));
	CloseHandle(data);
	PrintToChat(client, "test");
}
IF that's the only variable you're wanting to pass through, just pass that alone: (You probably already know this but It can help others)
Code:
public MenuHandler(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select)
	{
		SQL_TQuery(db, CheckDB "some query", GetClientUserid(param1));
	}
}

public CheckDB (Handle:owner, Handle:hndl, const String:error[], any:data)
{
	new client = GetClientOfUserId(data);
	PrintToChat(client, "test");
}
Drixevel is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-04-2015 , 00:49   Re: Problem with DataPacks
Reply With Quote #4

As a general rule, I do ResetPack as soon as I write the last data value. That way, even if you forget to ResetPack before reading, you've already reset it.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-04-2015 , 00:54   Re: Problem with DataPacks
Reply With Quote #5

Quote:
Originally Posted by r3dw3r3w0lf View Post
Here's how to fix that issue:
Code:
public MenuHandler(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select)
	{
		new Handle:data = CreateDataPack();
		WritePackCell(data, GetClientUserId(param1));
		SQL_TQuery(db, CheckDB "some query", data);
	}
}

public CheckDB (Handle:owner, Handle:hndl, const String:error[], any:data)
{
	ResetPack(data);
	new client = GetClientOfUserId(ReadPackCell(data));
	CloseHandle(data);
	PrintToChat(client, "test");
}
IF that's the only variable you're wanting to pass through, just pass that alone: (You probably already know this but It can help others)
Code:
public MenuHandler(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select)
	{
		SQL_TQuery(db, CheckDB "some query", GetClientUserid(param1));
	}
}

public CheckDB (Handle:owner, Handle:hndl, const String:error[], any:data)
{
	new client = GetClientOfUserId(data);
	PrintToChat(client, "test");
}
param1 is client already
8guawong is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 03-04-2015 , 01:58   Re: Problem with DataPacks
Reply With Quote #6

Quote:
Originally Posted by 8guawong View Post
param1 is client already
During a Threaded Query, the response time isn't instant so in that situation, It's best to get the client user ID and and revert it back on the other end just in case the client disconnects during the query.
Drixevel is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-04-2015 , 02:50   Re: Problem with DataPacks
Reply With Quote #7

Quote:
Originally Posted by r3dw3r3w0lf View Post
During a Threaded Query, the response time isn't instant so in that situation, It's best to get the client user ID and and revert it back on the other end just in case the client disconnects during the query.
oh ok i'll change it just incase , thanks!
8guawong 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:39.


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