SA-MP Forums Archive
how to check whether the vehicle is a player? - 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: how to check whether the vehicle is a player? (/showthread.php?tid=531234)



how to check whether the vehicle is a player? - joevega12 - 11.08.2014

I want to block entry to other players when they want to enter as a driver.

Код:
CMD:bmx(playerid, params[])
{
	if(Sklep[playerid][bmx] == 0)
	{
		GraczVeh = 1;
		new string[500];
		new Gname[MAX_PLAYER_NAME];
		GetPlayerName(playerid, Gname, sizeof(Gname));
		format(string, sizeof(string), "/Gracze/%s.ini",Gname);
		Sklep[playerid][bmx] = 1;
		dini_IntSet(string, "bmx", 1);
		SendClientMessage(playerid, C_CYAN, "Motion Of 3Run: {FFFFFF}Kupiles BMX'a");
	}else{
		new Index;
		new tmp2[256]; tmp2 = strtok(params,Index);
		new tmp3[256]; tmp3 = strtok(params,Index);
		if(SpawnedVehicles[playerid] != 0) DestroyVehicle(SpawnedVehicles[playerid]);
		GraczVeh = 1;
		new colour1, colour2;
		if(!strlen(tmp2)) colour1 = random(256); else colour1 = strval(tmp2);
		if(!strlen(tmp3)) colour2 = random(256); else colour2 = strval(tmp3);
		new Float:X,Float:Y,Float:Z;
		new Float:Angle;
		GetPlayerPos(playerid, X,Y,Z);
		GetPlayerFacingAngle(playerid,Angle);
		if(PrivateVehicles[playerid] != 0) DestroyVehicle(PrivateVehicles[playerid]);
		PrivateVehicles[playerid] = CreateVehicle(481, X+0,Y,Z, Angle, colour1, colour2, -1);
		PlayerPlaySound(playerid,1085,0,0,0);
		PutPlayerInVehicle(playerid,PrivateVehicles[playerid],0);
	}
	return 1;
}
Код:
{
	if(// if not this player this vehicle)
	{
		ShowPlayerLangDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Prywatny Pojazd", "Private Vehicle", "To nie twoj pojazd!\nMozesz kupic wlasny pod komenda /sklep", "This is not your vehicle\nBuy vehicles in /sklep", "Wyjdz", "Exit", "","");
		ClearAnimations(playerid);
		return 1;
	}
	return 1;
}



Re: how to check whether the vehicle is a player? - Kar - 11.08.2014

IsPlayerInAnyVehicle(playerid)

IsPlayerInVehicle(playerid, vehicleid)


Re: how to check whether the vehicle is a player? - iFarbod - 11.08.2014

Want to prevent the player from entering a car/vehicle? Then use OnPlayerEnterVehicle. GetPlayerPos and SetPlayerPos.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:pos[4];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    SetPlayerFacingAngle(playerid, pos[3]);
    return 1;
}
..

GetPlayerVehicleID. Returns 0 if player isn't in a vehicle. Returns the vehicle ID That the player is in it.


Re: how to check whether the vehicle is a player? - joevega12 - 11.08.2014

iFarbod, no...
I make private vehicles. If this vehicle belongs to the different player entering to vehicle showplayerdialog "this is not your vehicle!" and clearanimations(playerid);

Sorry for my engllish


Re: how to check whether the vehicle is a player? - joevega12 - 12.08.2014

Refresh


Re: how to check whether the vehicle is a player? - Hammomd - 12.08.2014

Quote:
Originally Posted by iFarbod
Посмотреть сообщение
Want to prevent the player from entering a car/vehicle? Then use OnPlayerEnterVehicle.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:pos[4];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    SetPlayerFacingAngle(playerid, pos[3]);
    return 1;
}
..

GetPlayerVehicleID. Returns 0 if player isn't in a vehicle. Returns the vehicle ID That the player is in it.
It can be but it's more easy RemovePlayerFromVehicle
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(// if vehicle isn't of the player)
    {
        RemovePlayerFromVehicle(playerid);
        ShowPlayerLangDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Prywatny Pojazd", "Private Vehicle", "To nie twoj pojazd!\nMozesz kupic wlasny pod komenda /sklep", "This is not your vehicle\nBuy vehicles in /sklep", "Wyjdz", "Exit", "","");
        ClearAnimations(playerid);
    }
    return 1;
}



Re: how to check whether the vehicle is a player? - joevega12 - 12.08.2014

I dont know this.
*
Код:
 * if(// if vehicle isn't of the player)
how to check


Re: how to check whether the vehicle is a player? - joevega12 - 12.08.2014

please help, how to make system private vehicles...