AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to send an array with natives? (https://forums.alliedmods.net/showthread.php?t=30058)

schnitzelmaker 06-21-2006 10:11

How to send an array with natives?
 
I want send the origin of a player from one Plugin to another with a native,but it dont work.

First Plugin:
Code:

native Protectornative(Float:_origin[3])

public eCountdown(){
 new Float:origin[3]
 entity_get_vector(1,EV_VEC_origin,origin)
 client_print(0,print_chat,"send:%d,%d,%d",origin[0],origin[1],origin[2])
 Protectornative(origin)
}

Second Plugin:
Code:

public plugin_natives(){
 register_native ( "Protectornative", "Pnative")
}

public Pnative(Float:torigin[]){
 client_print(0,print_chat,"native:%f,%f,%f",torigin[0],torigin[1],torigin[2])
}

I get as Floats 0.0.

VEN 06-21-2006 12:13

You registered a native with the style 0 while you use style 1 so should be:
Code:
register_native ( "Protectornative", "Pnative", 1)

You passing an array. Arrays in Pawn always passed by reference. For style-1 natives you should perform param_convert for every parameter which passed by reference:
Code:
public Pnative(Float:torigin[]){     param_convert(1) // we convert 1st parameter     client_print(0,print_chat,"native:%f,%f,%f",torigin[0],torigin[1],torigin[2]) }


All times are GMT -4. The time now is 07:58.

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