getproperty(0, "",(any number), value) function does not return what i want
#1

Hello there,

As the title says, i cant get the 'getproperty' function to return the string that i want..or at least not where i want it.

just printing it with print returns fine;
pawn Код:
setproperty(0, "",48, "FishingRod");

    new value[15];
    getproperty(0, "",Item[slot][Containid], value);
    print(value);
//returns FishingRod  *jeeej*
But then i thought..okay ..lets return it in a dialog and first put it in format with other values;
pawn Код:
new FISH[15];
getproperty(0, "",Item[c][Containid], FISH);
           
new Cstring[120];
format(Cstring,sizeof(Cstring),"%s\n%d\n%s\n%d",FISH ,Item[c][ItemAmmount],Item[c][Containid2],Item[c][ItemAmmount2]);
what am im doing wrong there ? the FISH part returns smilies and zero's now.
Reply
#2

did i asked the question in a way that nobody understands ? (bump)
Reply
#3

c should be same as slot its all defined under a loop called MAX_ITEMS...

heres to give you an idea what i want with it;


this is where 'slots' came from;
pawn Код:
CreateItem(objectid,Name[],ID,Float:X, Float:Y, Float:Z,iworld,iint,contains,ammount,contains2,ammount2)// contains[],
{
    new slot = -1;

    for(new i = 0; i < MAX_ITEMS; i ++)
    {
        if(Item[i][picked]) continue;

        slot = i;
        break;
    }

    if(slot == -1) return -1; // No free Slot
    Item[slot][ItemObject] = objectid;
    Item[slot][Itemid] = ID;
    Item[slot][DI][0] = X;
    Item[slot][DI][1] = Y;
    Item[slot][DI][2] = Z;
    Item[slot][ItemWorld] = iworld;
    Item[slot][ItemInt] = iint;
    Item[slot][Containid] = contains;
    Item[slot][ItemAmmount] = ammount;
    Item[slot][Containid2] = contains2;
    Item[slot][ItemAmmount2] = ammount2;
    format(Item[slot][ItemName], 24, Name);
    new value[15];
    getproperty(0, "",Item[slot][Containid], value);
    print(value);

//-----------------------
    Item[slot][I_Areaid] = CreateDynamicSphere(X, Y, Z, 2.0, iworld, iint, -1);//2.0 is area size
    Streamer_SetIntData(STREAMER_TYPE_AREA, Item[slot][I_Areaid], E_STREAMER_EXTRA_ID, slot); //i know what it does but not why :S

    Item[slot][I_Objectid] = CreateDynamicObject(objectid, X, Y, Z, 0.0, 0.0, 0.0, iworld, iint, -1, 50.0, 50.0);

    Item[slot][picked] = true;

    return slot;
}
end this is just under a command
pawn Код:
for(new c = 0; c < MAX_ITEMS; c ++)
    if(IsPlayerInDynamicArea(playerid,Item[c][Itemid]))
    {
    //check if crate is empty  ( empty dialog makes you crash )
        if(Item[c][Containid]<=0 && Item[c][Containid2] <= 0 && Item[c][ItemAmmount]<= 0 && Item[c][ItemAmmount2]<= 0)return SendClientMessage(playerid,COLOR_WHITE,"empty");
        else
        {

        new Nstring[20];
        format(Nstring,sizeof(Nstring),"%s contains",Item[c][ItemName]);//header of dialog
        if(Item[c][Containid] <=46||Item[c][Containid2] <=46)//check if its weapons first then get the name
        {
            new gunname[32],gunname2[32],Wstring[100];
            GetWeaponName(Item[c][Containid],gunname,sizeof(gunname));
            GetWeaponName(Item[c][Containid2],gunname2,sizeof(gunname2));
            format(Wstring,sizeof(Wstring),"%s\n%s",gunname,gunname2);
            ShowPlayerDialog(playerid,W_CONTANCE,DIALOG_STYLE_LIST,Nstring,Wstring,"get","leave");
           
        }
        if(Item[c][Containid] >46||Item[c][Containid2]>46) // if item is not a weapon
        {

            new VL[15];
            getproperty(0, "",Item[c][Containid], VL);
            //strunpack(VL,VL);
            new Cstring[120];
            format(Cstring,sizeof(Cstring),"%s\n%d\n%s\n%d",getproperty(0, "",Item[c][Containid], VL),Item[c][ItemAmmount],Item[c][Containid2],Item[c][ItemAmmount2]);
            ShowPlayerDialog(playerid,CONTANCE,DIALOG_STYLE_LIST,Nstring,Cstring,"get","leave");
            print(VL);

        }
        }
    }
Reply
#4

This is because property returns packed string. You need to unpack it (with strunpack()), when using format(), or working on it.
Reply
#5

Quote:
Originally Posted by gesior7
Посмотреть сообщение
This is because property returns packed string. You need to unpack it (with strunpack()), when using format(), or working on it.
This is 3 months old thread.. I think this problem is already solved.
Reply
#6

I hope, it's solved. Did you help AIped?
Reply
#7

Quote:
Originally Posted by gesior7
Посмотреть сообщение
I hope, it's solved. Did you help AIped?
I'm not but this is 3 old months thread man..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)