Choosing random mission
#1

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
Reply
#2

Use random() function.

https://sampwiki.blast.hk/wiki/Random
Reply
#3

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.
Reply
#4

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
Reply
#5

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 >.>
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)