Help with Random (Pilot Job) - 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)
+--- Thread: Help with Random (Pilot Job) (
/showthread.php?tid=656350)
Help with Random (Pilot Job) -
ImTobi - 14.07.2018
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;
}
Re: Help with Random (Pilot Job) -
Akeem - 14.07.2018
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.
Re: Help with Random (Pilot Job) -
ImTobi - 14.07.2018
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?
Re: Help with Random (Pilot Job) -
d1git - 14.07.2018
PHP код:
forward Flug(playerid);
public Flug(playerid) {
fCP[playerid] = random(4);
switch (fCP[playerid]) {
case 0, 1: SendClientMessage(playerid, COLOR_WHITE, "Fliege nun nach Los Santos um die Ware abzuliefern.");
case 2, 3: SendClientMessage(playerid, COLOR_WHITE, "Fliege nun nach Las Venturas um die Ware abzuliefern.");
}
TogglePlayerControllable(playerid, true);
return 1;
}
Re: Help with Random (Pilot Job) -
ImTobi - 14.07.2018
Quote:
Originally Posted by d1git
PHP код:
forward Flug(playerid);
public Flug(playerid) {
fCP[playerid] = random(4);
switch (fCP[playerid]) {
case 0, 1: SendClientMessage(playerid, COLOR_WHITE, "Fliege nun nach Los Santos um die Ware abzuliefern.");
case 2, 3: SendClientMessage(playerid, COLOR_WHITE, "Fliege nun nach Las Venturas um die Ware abzuliefern.");
}
TogglePlayerControllable(playerid, true);
return 1;
}
|
i can't use 0 because that's the standard value. But i think i have a solution
Re: Help with Random (Pilot Job) -
d1git - 14.07.2018
The "max" value in the random/minrandom function has to be +1, depending on what you want.