Raised This Month: $32 Target: $400
 8% 

Did i do something wrong?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 11-24-2015 , 15:04   Did i do something wrong?
Reply With Quote #1

view_as<DataPack>(dpHandle[i]).ReadString(cTableList[iArrayIdx], MAX_TABLENAME_SIZE);

dpHandle is "any" typed array which were sent by function callback.
and view them as DataPack for using methods.

but i got compile error message when i tries to compile this plugin.


// C:\Users\nickname\Desktop\script\include\umg/database.inc(154) : warning 215: expression has no effect
// C:\Users\nickname\Desktop\script\include\umg/database.inc(154) : error 001: expected token: ";", but found "."
// C:\Users\nickname\Desktop\script\include\umg/database.inc(154) : error 029: invalid expression, assumed zero
// C:\Users\nickname\Desktop\script\include\umg/database.inc(154) : error 017: undefined symbol "ReadString"

and i changed that into

DataPack dpData = view_as<DataPack>(dpHandle[i]);
dpData.ReadString(cTableList[iArrayIdx], MAX_TABLENAME_SIZE);

and all of errors are gone.

what's the problem?
__________________

Last edited by Starbish; 11-24-2015 at 15:04.
Starbish is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 11-24-2015 , 15:18   Re: Did i do something wrong?
Reply With Quote #2

never mind. i found a solution.

just wrap once more with ().



sol)

view_as<DataPack>(dpHandle[i]).ReadString(cTableList[iArrayIdx], MAX_TABLENAME_SIZE);

change into

(view_as<DataPack>(dpHandle[i])).ReadString(cTableList[iArrayIdx], MAX_TABLENAME_SIZE);
__________________
Starbish is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 11-24-2015 , 16:39   Re: Did i do something wrong?
Reply With Quote #3

The dpHandle[i] shouldn't need to be wrapped in parentheses...try view_as<DataPack>(dpHandle[i].ReadString(cTableList[iArrayIdx], MAX_TABLENAME_SIZE)); instead which should work "better" than the fix you found.
__________________
~Wliu

Last edited by Wliu; 11-24-2015 at 16:39.
Wliu is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-24-2015 , 17:09   Re: Did i do something wrong?
Reply With Quote #4

Quote:
Originally Posted by Wliu View Post
The dpHandle[i] shouldn't need to be wrapped in parentheses...try view_as<DataPack>(dpHandle[i].ReadString(cTableList[iArrayIdx], MAX_TABLENAME_SIZE)); instead which should work "better" than the fix you found.
I don't even have to try that to tell you that you'll get an error about dpHandle[i] not having a method ReadString.

ReadString is a DataPack method, hence why you need the parentheses around dpHandle[i].
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 11-24-2015 , 18:05   Re: Did i do something wrong?
Reply With Quote #5

Perhaps I should read the first post next time instead of reading the last reply. Didn't even stop to think about what dpHandle could have stood for.
__________________
~Wliu
Wliu is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 11-25-2015 , 02:17   Re: Did i do something wrong?
Reply With Quote #6

Quote:
Originally Posted by Wliu View Post
Perhaps I should read the first post next time instead of reading the last reply. Didn't even stop to think about what dpHandle could have stood for.
As far as i know, view_as operator must be used like this.

view_as<type>( var )

not this : view_as<type>var
__________________
Starbish is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 11-25-2015 , 08:16   Re: Did i do something wrong?
Reply With Quote #7

Yep, that's correct.
__________________
~Wliu
Wliu 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 21:50.


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