Multiple function arguments
Hello. I'm wondering, is there a way to create function which amounts of arguments depends on how that function is called. For instance a function like format() that can take 3 arguments 4, 5 etc...
|
Re: Multiple function arguments
Something like if I'm right and understand your question :
Code:
eg : MyFunction( "Hello %s ! Today %d %c %d - %f", "world", 21, ':', 38, 2009.0 ); will look : Code:
NewText = Hello world ! Today 21 : 38 - 2009.000000 |
Re: Multiple function arguments
Thank you. And what if I don't know approximate length of a Text.
Can I determine it somehow and create array appropriate for that string? Lengths of strings I would be using with that function can vary on different conditions. If I would adjust array length to longest string it would be simply a waste of server resources. edit> Thats what I'm trying to do Code:
|
Re: Multiple function arguments
public Handle:SQLQueryCreate(
Since your return an Handle type, you have to tag your function with Handle. Also, use sizeof not strlen. charsmax is macro from amxx 1.8.x which is : ( sizeof %1 - 1 ) |
Re: Multiple function arguments
Yeah I figured it out myself a while after editing. ;P
And what about that array issue? As you see I've declared sText 1024 long and I'm really not sure it would be enough. I hope there is a way to create string with dynamic length. |
Re: Multiple function arguments
Not possible AFAIK. I'm sure you can determine a max.
|
Re: Multiple function arguments
Well to bad, but I was about to change that function to normal SQL_PrepareQuery() anyway after I'll finish debuging. - Or not if you can tell me how to check if plugin is in debuging mode ( "plugin.amxx debug" in plugins.ini ) or not.
I still have two problems that are not especially connected to this topic, but those are probably caused by my stupid mistakes so I think they don't deserve another topic. So here it goes: 1. Weird number is being inserted/fetched to/from database. Code:
Code:
SELECT `sp_id` FROM `stats_player` WHERE `sp_steamid` = 'STEAM_0:1:12257932'Where first query is ok, second one is far from it as third value ( _sp_id ) I should get 14. What is going on? 2. To write players map time I want to use forwarding methods. Code:
Code:
[AMXX] Run time error 10: native error (native "ExecuteForward")Damn wrong button - still writing edit>> I think I'm done writing... sorry... |
Re: Multiple function arguments
How did you create the iPlayerID variable?
|
Re: Multiple function arguments
new iPlayerID
new Float:fPlayerID new sPlayerID[12] In first two cases result is the same ( 1096810496 ) When i tried retrieving id as string "SQL_ReadResult(InsertQuery_2, 0, sPlayerID, 11) i got 49 as id. |
Re: Multiple function arguments
Do you mind showing the full code for this function?
Also, are you using SQLx? Because I've never seen the SQLQueryCreate() function. |
| All times are GMT -4. The time now is 13:53. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.