SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/07/2018, 12:39 AM   #1
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 79
Reputation: 0
Default Help with Random (Pilot Job)

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

Code:
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;
	}
ImTobi is offline   Reply With Quote
Old 14/07/2018, 01:38 AM   #2
Akeem
Big Clucker
 
Join Date: Aug 2017
Location: Pun de Gaza
Posts: 70
Reputation: 0
Default Re: Help with Random (Pilot Job)

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.
Akeem is offline   Reply With Quote
Old 14/07/2018, 01:53 AM   #3
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 79
Reputation: 0
Default Re: Help with Random (Pilot Job)

Quote:
Originally Posted by Akeem View Post
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?
ImTobi is offline   Reply With Quote
Old 14/07/2018, 01:57 AM   #4
d1git
Big Clucker
 
Join Date: Sep 2015
Posts: 82
Reputation: 13
Default Re: Help with Random (Pilot Job)

PHP Code:
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;

d1git is offline   Reply With Quote
Old 14/07/2018, 01:59 AM   #5
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 79
Reputation: 0
Default Re: Help with Random (Pilot Job)

Quote:
Originally Posted by d1git View Post
PHP Code:
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
ImTobi is offline   Reply With Quote
Old 14/07/2018, 02:01 AM   #6
d1git
Big Clucker
 
Join Date: Sep 2015
Posts: 82
Reputation: 13
Default Re: Help with Random (Pilot Job)

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another day for a pilot Njale Screenshots and Videos 12 01/11/2016 10:35 AM
[Tutorial] Random Aspects - Using numargs(), getarg(...) and random(...) to make random systems dynamic and easier! SickAttack Tutorials 7 10/05/2015 10:39 AM
need a pilot gm 12kelvin12 Help Archive 1 06/04/2011 04:18 PM
[FilterScript] [FS][Job]Pilot Trooper[Y] Filterscripts 22 16/04/2009 01:25 PM


All times are GMT. The time now is 12:44 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.