Assigning a Float value to an array TAG MISMATCH
#1

I simply want to put the player's X/Y/Z coords into a static array, but I keep getting mismatches. Seems when you declare a value for an array cell, it must be numeric?

Код:
new Float:tX,Float:tY,Float:tZ;
GetPlayerPos(playerid, tX, tY, tZ);
camera[playerid][1] = tX;
camera[playerid][2] = tY;
camera[playerid][3] = tZ;
...\gamemodes\....pwn(89) : error 006: must be assigned to an array
...\gamemodes\....pwn(90) : error 006: must be assigned to an array
...\gamemodes\....pwn(91) : error 006: must be assigned to an array
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#2

pawn Код:
new Float:Position[3];
_________________________________________________

Or you can use enum:

pawn Код:
//top of script
enum bob
{
Float:X,
Float:Y,
Float:Z,
Float:Ang
}

new Position[bob];

//to save:
Position[X] = 10.0;
Position[Ang] = 180.0;

Reply
#3

I don't know anything about enum and who is bob? xD
Did I mention my array is already static?

Код:
#include <a_samp>
#include <core>
#include <float>

static camera[MAX_PLAYERS][4]; // [id][x][y][z]
Having said that, wouldn't using a 'new' Float as an array NOT be static?
Reply
#4

Why does it need to be static? As long as you don't change it there won't be a problem..

static Float:bob[10]; might work, try that..

I used Bob as the first word that came into my head (how exciting) and enum is quite useful when you get your head round it.. You can have floats variables and strings all in one big happy array.
Reply
#5

As far as I can tell it should be static... I'm making a script to place the camera at the current player's coords, then they can adjust the values after by adding/subtracting from them [x/y/z axis] to move the camera.

then a timer repeatedly checks to re-aim the lens at the player, without moving the camera's position from the would/should-be static position (?)
Reply
#6

Just because the cameras position is static doesn't mean the variables need to be. A Static variable is just one you can't change AFAIK. A normal variable is changed only when you tell it to.. As long as you don't code anything to change the values once set it will work..
Reply
#7

Quote:
Originally Posted by Weirdosport
Just because the cameras position is static doesn't mean the variables need to be. A Static variable is just one you can't change AFAIK. A normal variable is changed only when you tell it to.. As long as you don't code anything to change the values once set it will work..
I would like to inform you that you indeed can change values in a static array...

Secondly, these 3 axis values will be assigned as the players positon, as I said, but only once the function is initialized [when the player types /ccommandhere], then the difference is THEN added when they afterwards type [/xdif 5], [/ydif -10], [/zdif 25] (for example)

So,
Quote:
Originally Posted by Weirdosport
Just because the cameras position is static doesn't mean the variables need to be.
yes, they do, as they are merged to become 1 value, not 2 seperate factors in an equation to find the camera's new position.
Reply
#8

I'm fairly certain you can do everything you mentioned with variables..
Reply
#9

Sure, but then declaring the static array cells AS those variables seems to be the impossible part. I have to declare it using the GetPlayerPos(playerid,x,y,z), and NOT with 0, 15, 6000, whatever. NOT numbers.

Ugh...
Reply
#10

Maybe do this:

new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
camera[playerid][1] = X;
camera[playerid][2] = Y;
camera[playerid][3] = Z;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)