SendClientMessage return variables
#1

Hi all,

I have a problem with my idx variable.
The idx variable counts to 13 while it needs to be 2.
pawn Код:
if(!strcmp(cmdtext, "/test", true))
{
    HasClothes[playerid]=2;
    ClothesItems[playerid][1]=10;
        ClothesItems[playerid][2]=20;
        while( HasClothes[playerid]==idx )
        {
        idx ++;
    }
    for(new i = 0; i < idx; i++)
    {
        format( string, sizeof string, "slot %d|item id %d",idx,ClothesItems[playerid][idx]);
        SendClientMessage( playerid, -1, string );
    }
    return 1;
}
It needs to return:
Код:
slot 1|item id 10
slot 2|item id 20
Can someone correct this?

Thanks Admigo
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
That loop condition will only ever be true once.
So how can i fix this?
Reply
#3

I want to make a clothes system.
So what i need is to make a menu with the items that i own in the correct used slots.
Like in the test command:
pawn Код:
if(!strcmp(cmdtext, "/test", true))
{
    HasClothes[playerid]=2;//I am using 2 slots
    ClothesItems[playerid][1]=10;//slot 1 is using clothesid 10
    ClothesItems[playerid][2]=20;//slot 2 is using clothesid 20
    while( HasClothes[playerid]==idx )
    {
        idx ++;//count the slots that are using so i am using 2
    }
    for(new i = 0; i < idx; i++)//the counting slots getting returned here so i want 2 sendclientmessages
    {
        format( string, sizeof string, "slot %d|item id %d",idx,ClothesItems[playerid][idx]);//idx should be the slot number and itemid is the clothesid
        SendClientMessage( playerid, -1, string );
    }
    return 1;
}
So ingame it needs to return this as clientmessage:
Код:
slot 1|item id 10
slot 2|item id 20
Reply
#4

Quote:

Why not just use "HasClothes" in the loop directly?

Thanks, my bad.

Now i have:
pawn Код:
if(!strcmp(cmdtext, "/test", true))
{
    HasClothes[playerid]=2;//I am using 2 slots
    ClothesItems[playerid][1]=10;//slot 1 is using clothesid 10
    ClothesItems[playerid][2]=20;//slot 2 is using clothesid 20
    for(new i = 0; i < HasClothes[playerid]; i++)
    {
        format( string, sizeof string, "slot %d|item id %d",i,ClothesItems[playerid][i]);
        SendClientMessage( playerid, -1, string );
    }
    return 1;
}
But it returns ingame:
Код:
slot 0|item id 0
slot 1|item id 10
How to fix this?
Reply
#5

Unless I misunderstood your problem, this maybe the fix.
pawn Код:
if(!strcmp(cmdtext, "/test", true))
{
    HasClothes[playerid]=2;//I am using 2 slots
    ClothesItems[playerid][1]=10;//slot 1 is using clothesid 10
    ClothesItems[playerid][2]=20;//slot 2 is using clothesid 20
    for(new i = 1; i <= HasClothes[playerid]; i++)
    {
        format( string, sizeof string, "slot %d|item id %d",i,ClothesItems[playerid][i]);
        SendClientMessage( playerid, -1, string );
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)