31.07.2016, 15:39
Hello folks, I have tried many ways to avoid players from jacking NPC's car. Therefore, I felt to take help from Samp forum, Any idea, How can i lock driver's seat and allow the players to enter as passenger? Many players used to jack NPC's cars which always fucked the things up. Here are many codes:
I know the codes are werid thats why i came here.
PHP код:
#include <a_samp>
#include <streamer>
new taxi;
new bus;
public OnFilterScriptExit()
{
for(new i; i < MAX_PLAYERS; i++)
{
if(GetPlayerVirtualWorld(i) != 0 || GetPlayerInterior(i) != 0) TogglePlayerControllable(i, false);
}
}
public OnFilterScriptInit()
{
for(new i; i < MAX_PLAYERS; i++)
{
if(GetPlayerVirtualWorld(i) != 0 || GetPlayerInterior(i) != 0) TogglePlayerControllable(i, false);
}
taxi = AddStaticVehicle(420, 1631.9506, -1738.7668, 13.1301, -90.1200, 6, 6);//Bot's car
bus = AddStaticVehicle(431, 1650.6656, -1738.8820, 13.4544, -89.8800, 0, 0); //Bot's car
for(new i, Float: fPlayerPos[3]; i < MAX_PLAYERS; i++)
{
if(GetPlayerVirtualWorld(i) != 0 || GetPlayerInterior(i) != 0)
{
Streamer_UpdateEx(i, fPlayerPos[0], fPlayerPos[1], fPlayerPos[2]);
GetPlayerPos(i, fPlayerPos[0], fPlayerPos[1], fPlayerPos[2]);
SetPlayerPos(i, fPlayerPos[0], fPlayerPos[1], fPlayerPos[2] + 2.5);
TogglePlayerControllable(i, true);
}
}
// Headroom for static objects - streamed limits are completely independent (cause of old crashing)
Streamer_VisibleItems(STREAMER_TYPE_OBJECT, 958);
}
/*public OnVehicleStreamIn(vehicleid, forplayerid)
{
if(vehicleid == taxi) // if the vehicle that streams in is the vehicle you want to lock (Change YourVehicleIDHere)
{
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1); // lock the doors for the player
}
if(vehicleid == bus) // if the vehicle that streams in is the vehicle you want to lock (Change YourVehicleIDHere)
{
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1); // lock the doors for the player
}
return 1;
}*/
/*public OnVehicleStreamIn(vehicleid, forplayerid)
{
if(newstate == PLAYER_STATE_DRIVING)
{
SetVehicleParamsForPlayer(taxi, forplayerid, 0, 1); // lock the doors for the player
}
return 1;
}*/
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
SetVehicleParamsForPlayer(taxi, playerid, 0, 1); // lock the doors for the player
}
else
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_PASSENGER)
{
SetVehicleParamsForPlayer(taxi, playerid, 0, 0); // unlock the doors for the player
}
}
return 1;
}