SA-MP Forums Archive
how do you do this? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: how do you do this? (/showthread.php?tid=308009)



how do you do this? - HondaCBR - 01.01.2012

I made a command to show you all the vehicles you own.

pawn Код:
if(strcmp(cmd, "/veh", true) == 0)
    {
        if(PlayerInfo[playerid][pCarKey1] == 999 && PlayerInfo[playerid][pCarKey1] == 999)
        {
            SendClientMessage(playerid, COLOR_WHITE,"You can only own 2 vehicles");
            return 1;
        }
        new stringV[256];
        new option1[128];
        new option2[128];
        new CarFile[35];
        new CarFile2[35];
        format(CarFile,sizeof(CarFile),"Auta/%d.ini",PlayerInfo[playerid][pCarKey1]);
        new CarID = dini_Int(CarFile,"ModelID");
        format(CarFile2,sizeof(CarFile2),"Auta/%d.ini",PlayerInfo[playerid][pCarKey2]);
        new CarID2 = dini_Int(CarFile2,"ModelID");
        format(option1,sizeof(option1),"%s [UID: %d]",GetVehicleNameFromID(CarID),PlayerInfo[playerid][pCarKey1]);
        format(option2,sizeof(option2),"%s [UID: %d]",GetVehicleNameFromID(CarID2),PlayerInfo[playerid][pCarKey2]);
        format(stringV,sizeof(stringV),"%s\n%s",option1,option2);
        ShowPlayerDialog(playerid, VCMD, DIALOG_STYLE_LIST, "Your Vehicles:", stringV, "Spawn", "More");
        return 1;
    }
pawn Код:
if(dialogid == VCMD)
    {
        if(response)
        {
            //this is what im struggling with.
            {
Now, how can I create different action when you pick a vehicle, as IDK if that vehicle will be there? Should I globolize option1 and 2. And then use something like if(opion1) { }, or something?

Thx anyway.


Re: how do you do this? - Jefff - 01.01.2012

https://sampwiki.blast.hk/wiki/OnDialogResponse

listitem The ID of the list item selected by the player.


Re: how do you do this? - HondaCBR - 01.01.2012

I dont think that helps much, it shows me the original cases, what happens when you click on the first one or the 2nd one, i have this kind of dialog in my map. But in this case im going to have about 10 car slots, and you might end up seeing slot 7 and 10, I dont know if cases will work the same for this?


Re: how do you do this? - HondaCBR - 01.01.2012

BTW after adding GetVehicleNameFromID to this command, it comes up with server unknown command, and when I take it off, it works.

pawn Код:
if(strcmp(cmd, "/v", true) == 0)
    {
        if(PlayerInfo[playerid][pCarKey1] == 999 && PlayerInfo[playerid][pCarKey2] == 999)
        {
            SendClientMessage(playerid, COLOR_WHITE,"Nie masz zadnego samochodu");
            return 0;
        }
        new stringV[256];
        new option1[128];
        new option2[128];
        new CarFile[35];
        new CarFile2[35];
        format(CarFile,sizeof(CarFile),"Auta/%d.ini",PlayerInfo[playerid][pCarKey1]);
        format(CarFile2,sizeof(CarFile2),"Auta/%d.ini",PlayerInfo[playerid][pCarKey2]);
        new string12[128];
        new string13[128];
        format(string12, sizeof(string12), "%s",GetVehicleNameFromID(dini_Int(CarFile,"ModelID")));
        format(string13, sizeof(string13), "%s",GetVehicleNameFromID(dini_Int(CarFile2,"ModelID")));
        format(option1,sizeof(option1),"%s [UID: %d]",string12,PlayerInfo[playerid][pCarKey1]);
        format(option2,sizeof(option2),"%s [UID: %d]",string13,PlayerInfo[playerid][pCarKey2]);
        format(stringV,sizeof(stringV),"%s\n%s",option1,option2);
        ShowPlayerDialog(playerid, VCMD, DIALOG_STYLE_LIST, "Twoje pojazdy:", stringV, "Wybierz", "Zamknij");
        return 1;
    }



Re: how do you do this? - HondaCBR - 02.01.2012

Ignore the gettingvehiclenamefromid, Ill sort this out, the hardest thing is the dialogresponse, how can I link them them with the possible options? I cant use cases 0,1... as lets say you have 2 cars slot 5 and 6, then they would be the first 2 listed, and therefore case 0,case 1 will be used for them which is not what I want.