Checkpoint Mission Problem
#1

Ok, i have my script that i'm coding from scratch, and i'm trying to put in where you to to one place, then to a second place, and you get money. It is all supposed to be random on which mission you get. Now, i put 2 random missions in, and i'm not sure if it's not picking a random number or if it's cause there is only 2 numbers, but then the other problem is that the player will get the money on the first check point not the 2nd one, and... the 2nd checkpoint doesnt do anything..

I uploaded the entire thing to paste bin so that you can have a easy way of looking at it, Thanks in advance for any help you give.

http://pastebin.com/wnWdYdbE
Reply
#2

Would adding a timer after you get the new checkpoint fix the problem of it giving the money on the first run?!?
Reply
#3

use

somewhere in the script:
forward statechange(playerid);

in the first checkpoint case:

SetTimer("statechange", 5000, false);

public statechange(playerid)
{
Mission[playerid] =1;
}


so it will enable the mission after 5 sec and the player will get the money at the 2nd checkpoint ^^
Reply
#4

pawn Код:
random(2);
This will give you 0 or 1, so the code should be:

pawn Код:
if(strcmp(cmd, "/work", true) == 0)
    {
        new truckmission = random(2);
        if(truckmission == 0)
        {
            SetPlayerCheckpoint(playerid, -542.66851807,-499.06619263,26.67156410, 5.0);
            Mission[playerid] = 1;
        }
        else if(truckmission == 1)
        {
            SetPlayerCheckpoint(playerid, -2243.22705078,-2166.42480469,39.12138367, 5.0);
            Mission[playerid] = 2;
        }
    }
You need 'else if' to fix the second problem.

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(Mission[playerid] == 1)
    {
        SetPlayerCheckpoint(playerid, 1606.34802246,-2618.66137695,14.09705734,5.0);
        Mission[playerid] = 3;
    }
    else if(Mission[playerid] == 3)
    {
        SetPlayerMoney(playerid, GetPlayerMoney(playerid)+800);
        Mission[playerid] = 0;
        SendClientMessage(playerid, COLOR_GREEN, "Congrats $800");
    }
    else if(Mission[playerid] == 2)
    {
        SetPlayerCheckpoint(playerid, 1606.34802246,-2618.66137695,14.09705734,5.0);
        Mission[playerid] = 4;
    }
    else if(Mission[playerid] == 4)
    {
        SetPlayerMoney(playerid, GetPlayerMoney(playerid)+500);
        Mission[playerid] = 0;
        SendClientMessage(playerid, COLOR_GREEN, "Congrats $500");
    }
    return 1;
}
EDIT: Just noticed the posting date. I hate old topic bumpers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)