Converting a command to dialog
#1

Hello guys,

Im having a bit of a mindf*ck right now... i tried some thing but i cant get it to work.
i want to convert the /create [id] (creates a object at the players position) to where you type /create and it shows u a dialog with the available objects that you can make. heres the code:
(note that i already changed some stuff)
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new idx;
    new cmd[256];
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd,"/Create",true) == 0)
    {
        new tmp[128], Model, Float:x, Float:y, Float:z;
        new NewID = GetFurnitureID();
        tmp = strtok(cmdtext, idx);
        ShowPlayerDialog(playerid, Dialog_Objects, DIALOG_STYLE_LIST, "~b~Base Building", "Object 19353(wall)\nObject 39358(wall2)", "Select", "Close");
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, 0xBFC0C2FF, "Use: /Create");
            return 1;
        }
        Model = strval(tmp);

        if(NewID == -1) return SCM(playerid, 0xFF0000C8, "* No extra objects that you can not continue to create.");

        GetPlayerPos(playerid,x,y,z);
        FurnitureInfo[NewID][fID] = NewID;
        FurnitureInfo[NewID][fModel] = Model;
        FurnitureInfo[NewID][fX] = x +1;
        FurnitureInfo[NewID][fY] = y +1;
        FurnitureInfo[NewID][fZ] = z;
        FurnitureInfo[NewID][fRX] = 0;
        FurnitureInfo[NewID][fRY] = 0;
        FurnitureInfo[NewID][fRZ] = 0;
        FurnitureInfo[NewID][fvID] = GetPlayerVirtualWorld(playerid);
        FurnitureInfo[NewID][fInt] = GetPlayerInterior(playerid);
        FurnitureInfo[NewID][fLiftup] = false;
        CreateFurniture(NewID);
        SaveFurniture(NewID);
        return 1;
    }
        //rest of my commands
and heres the dialog stuff

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == Dialog_Objects)
    {
        if(response)
        {
            if(listitem == 0)
            {
                CreateObject(19353, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
            }
            if(listitem == 1)
            {
                CreateObject(19358, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
            }
        }
        return 1;
    }
    return 0;
}
im really confused on how to do this. i hope you guys can help me with an example so i can do the rest my self.
thanks!
Reply
#2

Never mind i fixed it my self !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)