28.11.2011, 20:58
(
Last edited by Gamer_Z; 29/11/2011 at 10:40 PM.
)
First of all Why I am posting here is because at other forums they woule be asking, what is AMX_Getarrd , what is this what is that.. everything related to the samp SDK.
*To mods: If you delete my topic at least let me know so I can try ASAP other methods of help!
Now the problem is that in my GPS plugin the function which stores an array to an vector works good when ran, but then immidiately after the function finishes (or a bit later) the first 43 variables change (at least that is what I see every time, every time the same numbers!)
Those numbers:
I've checked it multiple times, the same result on Linux and on Windows, It's not the script.
The 43 vars are always the same , everything after that results in a good variable, the one the pawn script set.
I'm working on it already a few weeks but I can't manage to fix it.
Here's the last thing I've done:
If anybody would like to help well.. the full source code is available at gpb.googlecode.com,
if you need it, the other prints I did use:
(btw sometimes they don't change immediately but a bit later or just not at all... but it happens often. at least on Kar's LVCNR. I would like to blame the script (that were my first thoughts) but it's really the plugin...
*To mods: If you delete my topic at least let me know so I can try ASAP other methods of help!
Now the problem is that in my GPS plugin the function which stores an array to an vector works good when ran, but then immidiately after the function finishes (or a bit later) the first 43 variables change (at least that is what I see every time, every time the same numbers!)
Those numbers:
pawn Code:
//GetRouteFromTo(...);
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[0]: 47
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[1]: 103
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[2]: 101
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[3]: 116
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[4]: 97
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[5]: 114
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[6]: 114
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[7]: 97
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[8]: 121
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[9]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[10]: 1
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[11]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[12]: 101
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[13]: 116
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[14]: 97
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[15]: 114
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[16]: 114
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[17]: 97
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[18]: 121
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[19]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[20]: 71
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[21]: 101
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[22]: 116
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[23]: 97
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[24]: 114
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[25]: 114
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[26]: 97
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[27]: 121
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[28]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[29]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[30]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[31]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[32]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[33]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[34]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[35]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[36]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[37]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[38]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[39]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[40]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[41]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[42]: 0
[21:49:13] [System CMD: getarray] - Getting Route Array - node_id_array[43]: 0
The 43 vars are always the same , everything after that results in a good variable, the one the pawn script set.
I'm working on it already a few weeks but I can't manage to fix it.
Here's the last thing I've done:
pawn Code:
//see "static cell AMX_NATIVE_CALL n_StoreArray( AMX* amx, cell* params )"
struct RouteData
{
cell * Paths;
int amount_of_nodes;
int id;
RouteData(cell *Paths_,int amount_of_nodes_, int id_)
{
Paths = NULL;
amount_of_nodes = NULL;
id = NULL;
Paths = Paths_;
amount_of_nodes = amount_of_nodes_;
id = id_;
}
};
vector <RouteData> RouteVector;
vector <int> RouteID;
static cell AMX_NATIVE_CALL n_StoreArray( AMX* amx, cell* params )
{
int IDcounter = 0;
for(int i = 0,j = RouteID.size(); i < j; ++i)
{
if(RouteID.at(i) == IDcounter)
{
i = 0;
IDcounter++;
}
}
cell *dest = NULL;
amx_GetAddr(amx,params[2],&dest);
int amount_of_nodes = params[1];
RouteID.push_back(IDcounter);
RouteVector.push_back(RouteData(dest,amount_of_nodes,IDcounter));
//Tried this to fix it:
for(int i = 0, j = amount_of_nodes; i < j; ++i)//doesn't fix it? :S <--- this
{
cout << i << "|" << RouteVector.back().Paths[i] << "|" << dest[i] << "\r\n";
RouteVector.back().Paths[i] = dest[i];
cout << i << "|" << RouteVector.back().Paths[i] << "|" << dest[i] << "\r\n";
}
//
return IDcounter;
}
if you need it, the other prints I did use:
pawn Code:
static cell AMX_NATIVE_CALL n_ReturnArray( AMX* amx, cell* params )
{
for(int i = 0, j = RouteVector.size(); i < j; ++i)
{
if(RouteVector.at(i).id == params[1])
{
cell *dest = NULL;
amx_GetAddr(amx,params[2],&dest);
cout << "n_ReturnArray --> params[1] == " << params[1] << " params[2] == " << params[2] << " params[3] == " << params[3] << " AMX Addr: " << dest << "|" << *dest << "\r\n";
for(int a = 0, b = params[3]; a < b; ++a)
{
cout << RouteVector.at(i).Paths[a] << "\r\n";
dest[a] = RouteVector.at(i).Paths[a];
}
return RouteVector.at(i).amount_of_nodes;
}
}
return 0;
}
static cell AMX_NATIVE_CALL n_GetRouteAtPos( AMX* amx, cell* params )
{
for(int i = 0, j = RouteVector.size(); i < j; ++i)
{
if(RouteVector.at(i).id == params[1])
{
if(RouteVector.at(i).amount_of_nodes > i)
{
cell *dest = NULL;
amx_GetAddr(amx,params[3],&dest);
cout << "n_GetRouteAtPos --> params[1] == " << params[1] << " params[2] == " << params[2] << " params[3] == " << params[3] << " AMX Addr: " << dest << "|" << *dest << "\r\n";
*dest = RouteVector.at(i).amount_of_nodes;
cout << "n_GetRouteAtPos(2) --> AMX Addr: " << dest << "|" << *dest << "\r\n";
return RouteVector.at(i).Paths[params[2]];
}
}
}
return 0;
}
static cell AMX_NATIVE_CALL n_GetRouteFromTo( AMX* amx, cell* params )
{
for(int i = 0, j = RouteVector.size(); i < j; ++i)
{
if(RouteVector.at(i).id == params[1])
{
cell *dest = NULL;
amx_GetAddr(amx,params[4],&dest);
cout << "n_GetRouteFromTo --> params[1] == " << params[1] << " params[2] == " << params[2] << " params[3] == " << params[3] << " params[4] == " << params[4] << " AMX Addr: " << dest << "|" << *dest << "\r\n";
int c = -1;
for(int a = params[2], b = params[3]; a < b; ++a)
{
c++;
if(c == params[5])
{
return c;
}
dest[c] = RouteVector.at(i).Paths[a];
cout << a << "|" << dest[c] << "|" << RouteVector.at(i).Paths[a] << "\r\n";
}
return c;
}
}
return 0;
}