Random Mis - 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: Random Mis (
/showthread.php?tid=653769)
Random Mis -
KamilPolska - 12.05.2018
I have a system made. I just don't know how to make 5 random missions.
https://pastebin.com/TdkXxWFw
Re: Random Mis -
TadePoleMG - 12.05.2018
hi
all cordinates are equal it means you can't make it as random.
Re: Random Mis -
KamilPolska - 12.05.2018
Yes. The only problem is I do not know how to make 5 random missions to be chosen in the dialogue.
Re: Random Mis -
KamilPolska - 13.05.2018
help plz
Re: Random Mis -
RoboN1X - 13.05.2018
Get this include:
https://sampforum.blast.hk/showthread.php?tid=343172
then shuffle the array with this:
http://forum.sa-mp.com/showpost.php?...postcount=4051
Make a copy of MisLocations array with size just 5, shuffle it with the function, loop through the copied array, concatenate each line then show the dialog.
Re: Random Mis -
KamilPolska - 13.05.2018
I do not know how to do it exactly.
https://pastebin.com/i07Wqm3X
Re: Random Mis -
TadePoleMG - 14.05.2018
Hi again
See this link, I think it may help you a lot.
LINK -
https://sampforum.blast.hk/showthread.php?tid=223550
Regards.
Re: Random Mis -
RoboN1X - 14.05.2018
Quote:
Originally Posted by KamilPolska
|
Well sorry for making you misunderstood. I didn't ask you to reduce your array until 5, you can keep it like before (10). I mean you can use it like this:
Код:
CMD:z(playerid, params[])
{
if(MissionStatus[playerid] == 0)
{
new LoadText[1000]; // dialog text buffer
LoadText = "Commadity\tPoint\tPrize"; // the dialog headers
ShuffleDeepArray(MisLocations); // random the order of array
for (new i = 0; i < 5; i++) // pick only first 5 missions randomly
{
format(LoadText, 1000, "%s\n{008000}%s\t{FFFF00}%s\t{FF0000}%d $", LoadText, MisLocations[i][Commadity], MisLocations[i][LoadName], MisLocations[i][Pay]);
}
ShowPlayerDialog(playerid, DIALOG_MISSION, DIALOG_STYLE_TABLIST_HEADERS, "MISSION", LoadText, "OK", "Cancel");
}
else
{
SendClientMessage(playerid, COLOR_RED, "/cancel !");
}
return 1;
}
Then you can add more missions on MisLocations array, just make sure it has more than 5 items otherwise it would be useless to shuffle (would not work if less!). Everytime the player type the command, they will always get different 5 random missions.
On the dialog response, get the inputtext to get the selected mission ID. You might get "{008000}1" where 1 is mission id and {008000} is the color embedding, you could delete the color embedding by deleting first 8 characters in string or just remove your color embedding code at the dialog command.
Hope that helps.
Re: Random Mis -
KamilPolska - 14.05.2018
Thanks !