SA-MP Forums Archive
PutPlayerInVehicle - 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: PutPlayerInVehicle (/showthread.php?tid=647258)



PutPlayerInVehicle - Thanks - 02.01.2018

I've creating a vehicles but I want make it OnPlayerSpawn Put him in random vehicle spawned.. if it Emety How to do that?

PHP код:
Infernus[1] = AddStaticVehicle(411,3076.3999000,-1772.1000000,59.8000000,270.0000000,000,245); //Infernus
    
AddVehicleComponent(Infernus[1], 1008);
    
AddVehicleComponent(Infernus[1], 1087);
    
AddVehicleComponent(Infernus[1], 1080);
    
ChangeVehiclePaintjob(Infernus[1], 2);
    
    
Infernus[2] = AddStaticVehicle(411,3076.6001000,-1791.3000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[2], 1008);
    
AddVehicleComponent(Infernus[2], 1087);
    
AddVehicleComponent(Infernus[2], 1080);
    
ChangeVehiclePaintjob(Infernus[2], 2);
    
    
Infernus[3] = AddStaticVehicle(411,3076.5000000,-1763.8000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[3], 1008);
    
AddVehicleComponent(Infernus[3], 1087);
    
AddVehicleComponent(Infernus[3], 1080);
    
ChangeVehiclePaintjob(Infernus[3], 2);
    
    
Infernus[4] = AddStaticVehicle(411,3076.6001000,-1775.5000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[4], 1008);
    
AddVehicleComponent(Infernus[4], 1087);
    
AddVehicleComponent(Infernus[4], 1080);
    
ChangeVehiclePaintjob(Infernus[4], 2);
    
    
    
Infernus[5] = AddStaticVehicle(411,3076.7000000,-1782.8000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[5], 1008);
    
AddVehicleComponent(Infernus[5], 1087);
    
AddVehicleComponent(Infernus[5], 1080);
    
ChangeVehiclePaintjob(Infernus[5], 2);
    
    
    
Infernus[6] = AddStaticVehicle(411,3076.6001000,-1786.5000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[6], 1008);
    
AddVehicleComponent(Infernus[6], 1087);
    
AddVehicleComponent(Infernus[6], 1080);
    
ChangeVehiclePaintjob(Infernus[6], 2);
    
    
    
Infernus[7] = AddStaticVehicle(411,3076.8999000,-1779.0000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[7], 1008);
    
AddVehicleComponent(Infernus[7], 1087);
    
AddVehicleComponent(Infernus[7], 1080);
    
ChangeVehiclePaintjob(Infernus[7], 2);
    
    
    
Infernus[8] = AddStaticVehicle(411,3076.6001000,-1796.9000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[8], 1008);
    
AddVehicleComponent(Infernus[8], 1087);
    
AddVehicleComponent(Infernus[8], 1080);
    
ChangeVehiclePaintjob(Infernus[8], 2);
    
    
    
Infernus[9] = AddStaticVehicle(411,3076.2998000,-1767.0996000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[9], 1008);
    
AddVehicleComponent(Infernus[9], 1087);
    
AddVehicleComponent(Infernus[9], 1080);
    
ChangeVehiclePaintjob(Infernus[9], 2);
    
    
    
Infernus[10] = AddStaticVehicle(411,3077.1001000,-1754.3000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[10], 1008);
    
AddVehicleComponent(Infernus[10], 1087);
    
AddVehicleComponent(Infernus[10], 1080);
    
ChangeVehiclePaintjob(Infernus[10], 2);
    
    
Infernus[11] = AddStaticVehicle(411,3076.8000000,-1757.5000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[11], 1008);
    
AddVehicleComponent(Infernus[11], 1087);
    
AddVehicleComponent(Infernus[11], 1080);
    
ChangeVehiclePaintjob(Infernus[11], 2);
    
    
    
Infernus[12] = AddStaticVehicle(411,3077.0000000,-1760.7002000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[12], 1008);
    
AddVehicleComponent(Infernus[12], 1087);
    
AddVehicleComponent(Infernus[12], 1080);
    
ChangeVehiclePaintjob(Infernus[12], 2);
    
    
    
Infernus[13] = AddStaticVehicle(411,3077.2000000,-1751.2000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[13], 1008);
    
AddVehicleComponent(Infernus[13], 1087);
    
AddVehicleComponent(Infernus[13], 1080);
    
ChangeVehiclePaintjob(Infernus[13], 2);
    
    
    
Infernus[14] = AddStaticVehicle(411,3077.3999000,-1741.7000000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[13], 1008);
    
AddVehicleComponent(Infernus[13], 1087);
    
AddVehicleComponent(Infernus[13], 1080);
    
ChangeVehiclePaintjob(Infernus[13], 2);
    
    
    
Infernus[15] = AddStaticVehicle(411,3077.2998000,-1748.2002000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[15], 1008);
    
AddVehicleComponent(Infernus[15], 1087);
    
AddVehicleComponent(Infernus[15], 1080);
    
ChangeVehiclePaintjob(Infernus[15], 2);
    
    
    
Infernus[16] = AddStaticVehicle(411,3077.2998000,-1745.2998000,59.8000000,270.0000000,000,000); //Infernus
    
AddVehicleComponent(Infernus[16], 1008);
    
AddVehicleComponent(Infernus[16], 1087);
    
AddVehicleComponent(Infernus[16], 1080);
    
ChangeVehiclePaintjob(Infernus[16], 2); 
I'TS Worked when Do! PutPlayerInVehicle(playerid, Infernus[0], 0); But i want make If vehicle is emety from players how?


Re: PutPlayerInVehicle - RogueDrifter - 02.01.2018

PHP код:
stock IsVehicleEmpty(vehicleid)
{
    for(new 
0,GetPlayerPoolSize();<= j;i++)
    {
        if(
GetPlayerVehicleID(i) == vehicleid) return 0;
        else return 
1;




Re: PutPlayerInVehicle - JaKe Elite - 02.01.2018

Not 100% tested but try this

PHP код:
stock PutInEmptyInfernus(playerid)
{
    for(new 
isizeof(Infernus); i++)
    {
        for(new 
aGetPlayerPoolSize(); <= ja++)
        {
            if(
IsPlayerInVehicle(aInfernus[i]) && GetPlayerState(a) == PLAYER_STATE_DRIVER)
                continue;
                
            
PutPlayerInVehicle(playeridInfernus[i], 0);
            break;
        }
    }
    return 
1;

USAGE:

PHP код:
public OnPlayerSpawn(playerid)
{
    
PutInEmptyInfernus(playerid);
    return 
1;

EDITED: Please make sure to reload the page I have edited the code, there were a few mistake on my first post


Re: PutPlayerInVehicle - Thanks - 02.01.2018

EDITED: I'll try it now!


Re: PutPlayerInVehicle - Thanks - 02.01.2018

So in OnPlayerSpawn do that?

PutPlayerInVehicle(playerid, Infernus[playerid], 0);


Re: PutPlayerInVehicle - RogueDrifter - 02.01.2018

Jesus Christ just put the function i gave you 'IsVehicleEmpty' before PutPlayerInVehicle, ex:
PHP код:
if(IsVehicleEmpty(infernus[number of the cell])
{
PutPlayer... 



Re: PutPlayerInVehicle - Thanks - 02.01.2018

Thanks worked!!


Re: PutPlayerInVehicle - JaKe Elite - 02.01.2018

Recheck the post that I have made once again, I have updated it 20 mins ago it is much more optimized


Re: PutPlayerInVehicle - Thanks - 02.01.2018

Hmm Thank you worked but can u help me with Vehicle Unpushed what mean.. When other players push your car nothing happend..


Re: PutPlayerInVehicle - Thanks - 03.01.2018

Any help? no errors / warrings


PHP код:
stock PutInEmptyInfernus(playerid)
{
    for(new 
isizeof(Infernus); i++)
    {
        for(new 
aGetPlayerPoolSize(); <= ja++)
        {
            if(
IsPlayerInVehicle(aInfernus[i]) && GetPlayerState(a) == PLAYER_STATE_DRIVER)
                continue;
            
PutPlayerInVehicle(playeridInfernus[i], 0);
            break;
        }
    }
    return 
1;

Код:
public OnPlayerSpawn(playerid)
{
	PutInEmptyInfernus(playerid);
The problem is when players Spawned all Driver in 1Car idk why!! HELP ME