SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Help put player in vehicle (https://forum.sa-mp.com/showthread.php?t=676084)

Calinut200 29/05/2020 01:10 PM

Help put player in vehicle
 
Helo Guys! I have a race system and i have some problems.
When the race lobby is 2/2 the race will start and only first player will be put in the vehicle created
How to make if are 5 players in race to put each player in diferent car.
Thank you in advance
PHP Code:

stock racelobby(playerid)
{
    if(
raceplayers 2)
    {
        
sendtorace(-1"Waiting for players");
    }
    else if(
raceplayers >= 2)
    {
        
sendtorace(-1"THE RACE WILL START IN 10 SECONDS");
        
SetTimer("race"100000);
    }
}
forward race(playerid);
public 
race(playerid)
{
    
SendClientMessageToAll(-1"DEBUG: RACE StART");
    
racestatus 1;
    new 
car1 CreateVehicle(411, -2518.1865, -2301.781714.8012, -90.0000, -1, -1100);
    new 
car2 CreateVehicle(411, -2517.9319, -2307.267814.8012, -90.0000, -1, -1100);
    
PutPlayerInVehicle(playeridcar10);
    
SendClientMessage(playerid, -1"In 5 seconds the race will start");
    return 
1;



RedGun2015 29/05/2020 01:17 PM

Re: Help put player in vehicle
 
This is an example, you must create some position in order to create a car, because if you create the same car in the same location some players will be stucked there (only if you are using collision in your race system).

PHP Code:

stock racelobby(playerid)
{
    if(
raceplayers 2)
    {
        
sendtorace(-1"Waiting for players");
    }
    else if(
raceplayers >= 2)
    {
        
sendtorace(-1"THE RACE WILL START IN 10 SECONDS");
        
SetTimer("race"100000);
    }
}

forward race();
public 
race()
{
    
SendClientMessageToAll(-1"DEBUG: RACE StART");
    
racestatus 1;
    
    foreach(new 
Player)
    {
        new 
car CreateVehicle(411, -2518.1865, -2301.781714.8012, -90.0000, -1, -1100);
        
PutPlayerInVehicle(icar0);
        
SendClientMessage(i, -1"In 5 seconds the race will start");
    }

    return 
1;




All times are GMT. The time now is 01:38 PM.

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