01.02.2013, 09:19
(
Last edited by Swimor; 01/02/2013 at 05:07 PM.
)
Hey,
I'm trying to change integer variable value from plugin,
Here the native:
And the plugin codE:
Usage:
But inter is still 0 (zero), but I changed him to 1 (one).
Why it's not working?
Update:
Fuck, Kyosaur you are awesome!
I found the answer in the plugin development tutorial:
Update:
I trying to set string into array, like:
But It setting the whole array, not array[idx],
Code i useD:
And I got:
I'm trying to change integer variable value from plugin,
Here the native:
Code:
native test(&int);
Code:
cell AMX_NATIVE_CALL test(AMX* amx, cell* params)
{
cell *dest = NULL;
amx_GetAddr(amx,params[1],&dest);
dest= (cell*)1;
return 1;
}
Code:
new
inter;
test(inter);
printf("%d", inter);
Why it's not working?
Update:
Fuck, Kyosaur you are awesome!
I found the answer in the plugin development tutorial:
Code:
//This function demonstrates: How to pass parameters by reference.
//PAWN native: native SetPawnReferenceVars(&value1, &Float:value2);
cell AMX_NATIVE_CALL SetPawnReferenceVars(AMX* amx, cell* params)
{
const int val = 65;
const float val2 = 84.54f;
cell* addr[2] = {NULL, NULL};
//Get the addresses of "value1" and "value2"
amx_GetAddr(amx, params[1], &addr[0]);
amx_GetAddr(amx, params[2], &addr[1]);
//Dereference our pointers and assign our values. Remember to ALWAYS use the macro "amx_ftoc" to convert floats into
//cells (the appropriate float format for PAWN)!
*addr[0] = val;
*addr[1] = amx_ftoc(val2);
return 1;
}
Update:
I trying to set string into array, like:
Code:
new array[32][32]; SetArray(array, sizeof(array));
Code i useD:
Code:
cell *arr = NULL;
amx_GetAddr(amx,params[2],&arr);
amx_SetString(&arr[0], "test0", 0, 0, strlen("test") + 1);
amx_SetString(&arr[1], "test1", 0, 0, strlen("test") + 1);
amx_SetString(&arr[2], "test2", 0, 0, strlen("test") + 1);
amx_SetString(&arr[3], "test3", 0, 0, strlen("test") + 1);
Quote:
|
ttttest3 |

