SA-MP Forums Archive
Choosing random mission - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Choosing random mission (/showthread.php?tid=177785)



Choosing random mission - Haydz - 19.09.2010

I would have searched the wiki but had no idea what to search so i posted here.

I was wondering how i could make it so it randomly picked a mission everytime a player did /work
This is my script: http://pastebin.com/cMxrD0aB

Thanks in advance


Re: Choosing random mission - MadeMan - 19.09.2010

Use random() function.

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


Re: Choosing random mission - Jochemd - 19.09.2010

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/work", cmdtext, true, 10) == 0)
    {
        new rand = random(3); // make this as high as you want.. depends on how much missions you want.
        if(rand == 0)
        {
            SendClientMessage(playerid, 0xFFFF00AA,"You are delivering Waste from Los Santos Airport to Landfill");
            SetPlayerCheckpoint(playerid, -694.9723, -1906.2748, 11.6886, 10.0);
        {
        else if(rand == 1)
        {
            //other stuff here
        }
        else if(rand == 2)
        {
            // any other stuff here
        }
        return 1;
    }
    return 0;
}
Try this.


Re: Choosing random mission - LarzI - 19.09.2010

Correction:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/work", cmdtext, true))
    {
        new rand = random(3); // make this as high as you want.. depends on how much missions you want.
        switch(rand)
    {
        case 0:
            {
                SendClientMessage(playerid, 0xFFFF00AA,"You are delivering Waste from Los Santos Airport to Landfill");
                SetPlayerCheckpoint(playerid, -694.9723, -1906.2748, 11.6886, 10.0);
            {
            case 1:
            {
                //other stuff here
            }
            case 2:
            {
                // any other stuff here
            }
    }
        return 1;
    }
    return 0;
}
Much better imo
And yes, indentation is fucked.. CBA to fix it up


Re: Choosing random mission - Mike_Peterson - 19.09.2010

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Much better imo
And yes, indentation is fucked.. CBA to fix it up
to fix indentation use
Код:
#pragma unused tabs
at top of ur script xD
i agree with "CBA to fix it up" Hate it >.>


Re: Choosing random mission - LarzI - 19.09.2010

lol...
I just couldn't be arsed replacing tabs with 4 spaces or vise versa.