PDA

View Full Version : How can I place a probability between two routes?


Leandrohei
18/03/2019, 10:51 PM
Sorry for my bad English

Well, a few months ago I downloaded a RP base game mode to make a server, and I was doing the work. Everything is fine, I watched many tutorials and they helped me a lot. The problem is that when the player joins the job and places / rutabus (since it's a bus driver job), it just gives a route, which I did in the script. What I am looking for is to be able to make more routes, and that when the player places / rutabus, I give him one at random. Here my code


COMMAND:
COMMAND:rutabus(playerid, cmdtext)
{
if (!IsPlayerInRangeOfPoint(playerid, 5.0, 2011.9757,-2099.0300,13.5469))
{
return SendClientMessage(playerid, 0xFF0000FF, "No estas cerca de el trabajo de chofer de larga distancia");
}
micrerobb[playerid] = 1; // This will change the variable, so we can use it later on with OnPlayerEnterCheckpoint
SetPlayerCheckpoint(playerid, 2013.0076,-2061.3867,13.2737, 10.0); // This creates a checkpoint at the co?rdinates: "-269.1287,2610.6057,63.2069"
SendClientMessage(playerid, 0xFFFF00AA, "Iniciaste la ruta de chofer de larga distancia");
SendClientMessage(playerid, 0xFFFF00AA, "La ruta de hoy es Los Santos - BlueBerry");
SendClientMessage(playerid, 0xFFFF00AA, "¡Ve a un bus y segui los checkpoints!");
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if(micrerobb[playerid] == 1){
micrerobb[playerid] = 2;
SetPlayerCheckpoint(playerid,1495.5216,-1588.7761,13.1099,5);
SendClientMessage(playerid, 0xFFFF00AA, "Los pasajeros ya subieron, ahora tenes que ir a la parada intermedia!");
return 1;
}
if(micrerobb[playerid] == 2){
micrerobb[playerid] = 3;
SetPlayerCheckpoint(playerid,317.6990,-17.8283,1.3052,5);
SetTimerEx("pasajeros subiendo...", 5000, 0, "i", playerid);
SendClientMessage(playerid, 0xFFFF00AA, "¡Los pasajeros ya subieron!, ahora si, ve a la terminal de buses de BlueBerry");
return 1;
}
if(micrerobb[playerid] == 3){
micrerobb[playerid] = 4;
SetPlayerCheckpoint(playerid,310.9017,-18.0067,1.3056,5);
SendClientMessage(playerid, 0xFFFF00AA, "¡Bien hecho!, ahora tenemos que volver a Los Santos, ve al checkpoint");
return 1;
}
if(micrerobb[playerid] == 4){
micrerobb[playerid] = 5;
SetPlayerCheckpoint(playerid,1601.3608,-1735.8271,13.1099,10);
SendClientMessage(playerid, 0xFFFF00AA, "¡Los pasajeros ya subieron!, ahora si, vayamos a la parada intermedia");
return 1;
}
if(micrerobb[playerid] == 5){
micrerobb[playerid] = 6;
SetPlayerCheckpoint(playerid,2028.4951,-2061.6758,13.2740,10);
SendClientMessage(playerid, 0xFFFF00AA, "¡Bien hecho! Ahora vayamos a la terminal central de buses Los Santos");
return 1;
}
if(micrerobb[playerid] == 6){
micrerobb[playerid] = 0;
SendClientMessage(playerid, 0xFFFF00AA, "Bien hecho, espera que los pasajeros bajen");
SendClientMessage(playerid, 0xFFFF00AA, "Felicidades!. Completaste la ruta correctamente. Recibiste $3000");
GivePlayerMoney(playerid, 3000);
DisablePlayerCheckpoint(playerid);
return 1;
}
}
return 1;
}

My other route ...

}
if(micrerobb2[playerid] == 1){
micrerobb2[playerid] = 2;
SetPlayerCheckpoint(playerid,1495.5216,-1588.7761,13.1099,5);
SendClientMessage(playerid, 0xFFFF00AA, "Los pasajeros ya subieron, ahora tenes que ir a la parada intermedia!");
return 1;
}
if(micrerobb2[playerid] == 2){
micrerobb2[playerid] = 3;
SetPlayerCheckpoint(playerid,317.6990,-17.8283,1.3052,5);
SetTimerEx("pasajeros subiendo...", 5000, 0, "i", playerid);
SendClientMessage(playerid, 0xFFFF00AA, "¡Los pasajeros ya subieron!, ahora si, ve a la terminal de buses de San Fierro");
return 1;
}
if(micrerobb2[playerid] == 3){
micrerobb2[playerid] = 4;
SetPlayerCheckpoint(playerid,-235.1712,-2943.3865,-0.6991,5);
SendClientMessage(playerid, 0xFFFF00AA, "¡Bien hecho!, ahora tenemos que volver a Los Santos, ve al checkpoint");
return 1;
}
if(micrerobb2[playerid] == 4){
micrerobb2[playerid] = 5;
SetPlayerCheckpoint(playerid,1601.3608,-1735.8271,13.1099,10);
SendClientMessage(playerid, 0xFFFF00AA, "¡Los pasajeros ya subieron!, ahora si, vayamos a la parada intermedia");
return 1;
}
if(micrerobb2[playerid] == 5){
micrerobb2[playerid] = 6;
SetPlayerCheckpoint(playerid,2028.4951,-2061.6758,13.2740,10);
SendClientMessage(playerid, 0xFFFF00AA, "¡Bien hecho! Ahora vayamos a la terminal central de buses Los Santos");
return 1;
}
if(micrerobb2[playerid] == 6){
micrerobb2[playerid] = 0;
SendClientMessage(playerid, 0xFFFF00AA, "Bien hecho, espera que los pasajeros bajen");
SendClientMessage(playerid, 0xFFFF00AA, "Felicidades!. Completaste la ruta correctamente. Recibiste $3000");
GivePlayerMoney(playerid, 3000);
DisablePlayerCheckpoint(playerid);
return 1;
}
}
return 1;
}


Returning to the question, how can I do when the player writes / rutabus assign one of the two routes?
I read what can be done with the dialogues, but my idea is not that the player chooses, but that it is aeleatoriamente. Thanks for your help beforehand

Pottus
18/03/2019, 11:50 PM
Take a look at this. Also your system and the way you are doing it needs some major improvements. This is a dynamic system but instead is hard coded with copy/paste code.

https://forum.sa-mp.com/showthread.php?t=662109

Leandrohei
19/03/2019, 12:09 AM
It seems very good complement, maybe I use it later, but I think you did not understand my question. I have the command to start the bus driver's work, and when that command is executed, the route starts. I want that when the player puts the command more than one route.
Example:
I made the route Los Santos - Blueberry, when the player places the command to start the route, start that path.
I want to make more routes, and that when the player puts the command it will be randomized
Do you understand I'm sure you can, but I could not find how