AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Enum vectors (https://forums.alliedmods.net/showthread.php?t=308078)

CrazY. 06-05-2018 14:24

[ H3LP ] Enum vectors
 
Hello, I'm getting compilation error when I do this (array sizes do not match, or destination array is too small)

Code:
enum _:eVectors {     Float:ORIGIN[3],     Float:ANGLES[3], }; public something(pPlayer) {     new stVector[eVectors];     ArrayGetArray(g_arrSpawns, random(ArraySize(g_arrSpawns)), stVector);     entity_set_vector(pPlayer, EV_VEC_origin, stVector[ORIGIN]);     entity_set_vector(pPlayer, EV_VEC_origin, stVector[ANGLES]); }

I know I can simply do this:

Code:
enum _:eVectors {     Float:ORIGIN[3],     Float:ANGLES[3], }; public something(pPlayer) {     new stVector[eVectors], Float:vecOrigin[3], Float:vecAngles[3];     ArrayGetArray(g_arrSpawns, random(ArraySize(g_arrSpawns)), stVector);     vecOrigin[0] = stVector[ORIGIN][0];     vecOrigin[1] = stVector[ORIGIN][1];     vecOrigin[2] = stVector[ORIGIN][2];     vecAngles[0] = stVector[ANGLES][0];     vecAngles[1] = stVector[ANGLES][1];     vecAngles[2] = stVector[ANGLES][2];     entity_set_vector(pPlayer, EV_VEC_origin, vecOrigin);     entity_set_vector(pPlayer, EV_VEC_origin, vecAngles); }

But I want to know if it's possible to do WITHOUT create another two vectors and add to them.

Natsheh 06-05-2018 17:40

Re: [ H3LP ] Enum vectors
 
Code:

enum _:eVectors
{
    Float:ORIGIN[3],
    Float:ANGLES[3],
};

Extra comma.

Whats wrong with using xs include file

CrazY. 06-05-2018 20:26

Re: [ H3LP ] Enum vectors
 
No, extra comma is not the problem here. No one problem, it's just a question.

Garey 06-06-2018 16:58

Re: [ H3LP ] Enum vectors
 
I had same issue with Pawn, and i had 2 ways to solve this:
Code:

enum eVec3d
{
    ORIGIN,
    ANGLES
};

public something(pPlayer)
{
    new Float:stVector[eVec3d][3];
    entity_set_vector(pPlayer, EV_VEC_origin, stVector[ORIGIN]);
    entity_set_vector(pPlayer, EV_VEC_angles, stVector[ANGLES]);
}

and with temp var as you but use xs_vec_copy (to not assign one by one)

CrazY. 06-06-2018 19:54

Re: [ H3LP ] Enum vectors
 
The first method is what I'm looking for, thanks.


All times are GMT -4. The time now is 04:33.

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