GetPickupPos Extended
#1

Hey there i need help about
pawn Код:
new Float:blabla[][]={
{x,y,z},
{x,y,z},
{x,y,z}
}
new rand = random(sizeof(blabla));
new pickuppos = GetPickupPos(blabla[rand][0], blabla[rand][1],blabla[rand][2]);

stock GetPickupPos(Float:x,Float:y,Float:z)
{
    new Index=1;
    x=[Index][0]; // ITs error
    y=[Index][1];
    z=[Index][2];
    return 1;
//------------------------------------

However it gives warning & errors

(249)error 029: invalid expression, assumed zero
(249)warning 215: expression has no effect
(249)error 001: expected token: ";", but found "]"
(249)error 029: invalid expression, assumed zero
(249)fatal error 107: too many error messages on one line
//---I know the value is not give here---- but idk
    x=/*What should be added here*/[Index][0];
    y=/*What should be added here*/[Index][1];
    z=/*What should be added here*/[Index][2];

//----------------Something like inputtext from OnDialogResponse...?----------------------------
}
Hope i explained well
Reply
#2

pawn Код:
x=blabla[Index][0]; // ITs error
y=blabla[Index][1];
z=blabla[Index][2];
This will only return the coords of pickup 1, however..
Reply
#3

i know it and i am using it,
but i want it to be done as any name whatever i set
btw thnx for help
Reply
#4

I'm not sure I understand your question
Reply
#5

Quote:
Originally Posted by austin070
Посмотреть сообщение
pawn Код:
x=blabla[Index][0]; // ITs error
y=blabla[Index][1];
z=blabla[Index][2];
This will only return the coords of pickup 1, however..
pawn Код:
new Float:blabla[][]={
{x,y,z},
{x,y,z},
{x,y,z}
}
 new Float:newpickup[][]={
{x,y,z},
{x,y,z},
{x,y,z}
} new Float:giftpickup[][]={
{x,y,z},
{x,y,z},
{x,y,z}
}
 new Float:skinpickup[][]={
{x,y,z},
{x,y,z},
{x,y,z}
}
stock GetPickupPos1(Float:x,Float:y,Float:z)
stock GetPickupPos2(Float:x,Float:y,Float:z)
stock GetPickupPos3(Float:x,Float:y,Float:z)
stock GetPickupPos4(Float:x,Float:y,Float:z)
maybe this can help you understand?
if not,
Should i make stock for each random varible of pickup which will tell its position?
Reply
#6

Try using this I just made it quickly for you it's an include.

pawn Код:
#define             MAX_PICKUP_ARRAY            4096

#define PICKUP_BOUNDS(%0); if(%0 < 0 || %0 >= MAX_PICKUP_ARRAY) { \
    print("Pickup Index out of bounds"); \
    return -1;

enum PICKUPINFO
{
    gPickupID,
    gPickupType,
    gPickupModel,
    gPickupVW,
    Float:gPickupX,
    Float:gPickupY,
    Float:gPickupZ,
}

static PickupData[MAX_PICKUP_ARRAY][PICKUPINFO];

public OnGameModeInit()
{
    for(new i = 0; i < MAX_PICKUP_ARRAY; i++) PickupData[i][gPickupID] = -1;

    if (funcidx("PU_OnGameModeInit") != -1) return PU_OnGameModeInit();
    return 1;
}

#if defined _ALS_OnGameModeInit
    #undef OnGameModeInit
#else
    #define _ALS_OnGameModeInit
#endif
#define OnGameModeInit PU_OnGameModeInit
forward PU_OnGameModeInit();

stock AddPickup(model, type, Float:x, Float:y, Float:z, vw)
{
    for(new i = 0; i < MAX_PICKUP_ARRAY; i++)
    {
        if(PickupData[i][gPickupID] == -1)
        {
            PickupData[i][gPickupID] = CreatePickup(model, type, x, y, z, vw);
            PickupData[i][gPickupType] = type;
            PickupData[i][gPickupModel] = model;
            PickupData[i][gPickupVW] = vw;
            PickupData[i][gPickupX] = x
            PickupData[i][gPickupY] = y
            PickupData[i][gPickupZ] = z'
            return i;
        }
    }
    printf("AddPickup::Too many pickups");
    return -1;
}

stock DeletePickup(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1)
    {
        DestroyPickup(PickupData[index][gPickupID]);
        PickupData[index][gPickupID] = -1;
    }
    printf("DeletePickup::Pickup does not exist");
    return 0;
}

stock GetPickupPos(index, &Float:x, &Float:y, &Float:z)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1)
    {
        x = PickupData[index][gPickupX];
        y = PickupData[index][gPickupY];
        z = PickupData[index][gPickupZ];
        return 1;
    }
    printf("GetPickupPos::Pickup does not exist");
    return 0;
}

stock GetPickupVW(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupVW]
    printf("GetPickupVW::Pickup does not exist");
    return -1;
}

stock GetPickupID(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupID]
    printf("GetPickupID::Pickup does not exist");
    return -1;
}

stock GetPickupModel(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupModel]
    printf("GetPickupModel::Pickup does not exist");
    return -1;
}

stock GetPickupType(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupType]
    printf("GetPickupType::Pickup does not exist");
    return -1;
}

CMD:testpickup(playerid, arg[])
{
    new index = AddPickup(3337, 1, 1.0, 2.0, 3.0, 10);
    new Float:x, Float:y, Float:z, vw, id, model, type;
    GetPickupPos(index, x, y, z);
    vw = GetPickupVW(index);
    id = GetPickupID(index);
    model = GetPickupModel(index);
    type = GetPickupType(index);
    printf("Pos:%f,%f,%f vw: %i id: %i Model: %i Type: %i", x, y, z, vw, id, model, type);
    return 1;
}
Reply
#7

Well thnx for making it for me
pawn Код:
pawno\include\YSI\y_iterate.inc(646) : error 017: undefined symbol "Itter_OnPlayerConnect"
pawno\include\PickupPos.inc(24) : error 004: function "PU_OnGameModeInit" is not implemented
Plz fix this problem i cannot
and
i suggest you to Release it officially. it will be helpful for everyone whoever need this.
Reply
#8

Are you compiling this into a gamemode or a filterscript ?

I won't release not really worth it to be honest.
Reply
#9

in a gamemode

as u wish.
Reply
#10

If your using YSI try it like this then.

pawn Код:
#include <YSI\y_hooks>

#define             MAX_PICKUP_ARRAY            4096

#define PICKUP_BOUNDS(%0); if(%0 < 0 || %0 >= MAX_PICKUP_ARRAY) { \
    print("Pickup Index out of bounds"); \
    return -1;

enum PICKUPINFO
{
    gPickupID,
    gPickupType,
    gPickupModel,
    gPickupVW,
    Float:gPickupX,
    Float:gPickupY,
    Float:gPickupZ,
}

static PickupData[MAX_PICKUP_ARRAY][PICKUPINFO];

hook OnGameModeInit()
{
    for(new i = 0; i < MAX_PICKUP_ARRAY; i++) PickupData[i][gPickupID] = -1;
    return 1;
}

stock AddPickup(model, type, Float:x, Float:y, Float:z, vw)
{
    for(new i = 0; i < MAX_PICKUP_ARRAY; i++)
    {
        if(PickupData[i][gPickupID] == -1)
        {
            PickupData[i][gPickupID] = CreatePickup(model, type, x, y, z, vw);
            PickupData[i][gPickupType] = type;
            PickupData[i][gPickupModel] = model;
            PickupData[i][gPickupVW] = vw;
            PickupData[i][gPickupX] = x
            PickupData[i][gPickupY] = y
            PickupData[i][gPickupZ] = z'
            return i;
        }
    }
    printf("AddPickup::Too many pickups");
    return -1;
}

stock DeletePickup(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1)
    {
        DestroyPickup(PickupData[index][gPickupID]);
        PickupData[index][gPickupID] = -1;
    }
    printf("DeletePickup::Pickup does not exist");
    return 0;
}

stock GetPickupPos(index, &Float:x, &Float:y, &Float:z)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1)
    {
        x = PickupData[index][gPickupX];
        y = PickupData[index][gPickupY];
        z = PickupData[index][gPickupZ];
        return 1;
    }
    printf("GetPickupPos::Pickup does not exist");
    return 0;
}

stock GetPickupVW(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupVW]
    printf("GetPickupVW::Pickup does not exist");
    return -1;
}

stock GetPickupID(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupID]
    printf("GetPickupID::Pickup does not exist");
    return -1;
}

stock GetPickupModel(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupModel]
    printf("GetPickupModel::Pickup does not exist");
    return -1;
}

stock GetPickupType(index)
{
    PICKUP_BOUNDS(index);
    if(PickupData[index][gPickupID] > -1) return PickupData[index][gPickupType]
    printf("GetPickupType::Pickup does not exist");
    return -1;
}

CMD:testpickup(playerid, arg[])
{
    new index = AddPickup(3337, 1, 1.0, 2.0, 3.0, 10);
    new Float:x, Float:y, Float:z, vw, id, model, type;
    GetPickupPos(index, x, y, z);
    vw = GetPickupVW(index);
    id = GetPickupID(index);
    model = GetPickupModel(index);
    type = GetPickupType(index);
    printf("Pos:%f,%f,%f vw: %i id: %i Model: %i Type: %i", x, y, z, vw, id, model, type);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)