Help with Random (Pilot Job)
#1

I have a problem.
My Flight Checkpoint is firstly at San Fierro Airport if you start the Job.
Then if you drive into it, it should wait 5 Seconds and then randomly choose Los Santos or Las Venturas as Next Checkpoint, but i only get Los Santos

Код:
forward Flug(playerid);
public Flug(playerid)
{
	fCP[playerid] = minrand(2,3);
	TogglePlayerControllable(playerid, true);
	if(fCP[playerid] == 2)
	{
		SendClientMessage(playerid, COLOR_WHITE, "Fliege nun nach Los Santos um die Ware abzuliefern.");
		return 1;
	}
	if(fCP[playerid] == 3)
	{
		SendClientMessage(playerid, COLOR_WHITE, "Fliege nun nach Las Venturas um die Ware abzuliefern.");
		return 1;
	}
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	if(GetPVarInt(playerid,"FlugJob") == 1)
	{
		if(fCP[playerid] == 1)
		{
			GameTextForPlayer(playerid, "~g~Ware wird aufgeladen...", 5000, 3);
			TogglePlayerControllable(playerid, false);
			SetTimerEx("Flug", 5000, false, "i", playerid);
			return 1;
		}
		return 1;
	}
Reply
#2

How much times you test this because I think the random is just calling LS location. I don't see anything wrong with the code, but i think you should increase the chances of getting both.
Reply
#3

Quote:
Originally Posted by Akeem
Посмотреть сообщение
How much times you test this because I think the random is just calling LS location. I don't see anything wrong with the code, but i think you should increase the chances of getting both.
How can i increase the chance?

Like: minrand(2,5)
and then 2 and 3 is ls
and 4 and 5 is lv?
Reply
#4

PHP код:
forward Flug(playerid);
public 
Flug(playerid) {
    
fCP[playerid] = random(4);
    switch (
fCP[playerid]) {
        case 
01SendClientMessage(playeridCOLOR_WHITE"Fliege nun nach Los Santos um die Ware abzuliefern.");
        case 
23SendClientMessage(playeridCOLOR_WHITE"Fliege nun nach Las Venturas um die Ware abzuliefern.");
    }
    
TogglePlayerControllable(playeridtrue);
    
    return 
1;

Reply
#5

Quote:
Originally Posted by d1git
Посмотреть сообщение
PHP код:
forward Flug(playerid);
public 
Flug(playerid) {
    
fCP[playerid] = random(4);
    switch (
fCP[playerid]) {
        case 
01SendClientMessage(playeridCOLOR_WHITE"Fliege nun nach Los Santos um die Ware abzuliefern.");
        case 
23SendClientMessage(playeridCOLOR_WHITE"Fliege nun nach Las Venturas um die Ware abzuliefern.");
    }
    
TogglePlayerControllable(playeridtrue);
    
    return 
1;

i can't use 0 because that's the standard value. But i think i have a solution
Reply
#6

The "max" value in the random/minrandom function has to be +1, depending on what you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)