NPC's Car.
#1

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:

PHP код:
#include <a_samp>
#include <streamer>
new taxi;
new 
bus;
public 
OnFilterScriptExit()
{
    for(new 
iMAX_PLAYERSi++)
    {
        if(
GetPlayerVirtualWorld(i) != || GetPlayerInterior(i) != 0TogglePlayerControllable(ifalse);
    }
}
public 
OnFilterScriptInit()
{
    for(new 
iMAX_PLAYERSi++)
    {
        if(
GetPlayerVirtualWorld(i) != || GetPlayerInterior(i) != 0TogglePlayerControllable(ifalse);
    }
    
taxi AddStaticVehicle(4201631.9506, -1738.766813.1301, -90.120066);//Bot's car
    
bus AddStaticVehicle(4311650.6656, -1738.882013.4544, -89.880000); //Bot's car
    
for(new iFloatfPlayerPos[3]; MAX_PLAYERSi++)
    {
        if(
GetPlayerVirtualWorld(i) != || GetPlayerInterior(i) != 0)
        {
            
Streamer_UpdateEx(ifPlayerPos[0], fPlayerPos[1], fPlayerPos[2]);
            
GetPlayerPos(ifPlayerPos[0], fPlayerPos[1], fPlayerPos[2]);
            
SetPlayerPos(ifPlayerPos[0], fPlayerPos[1], fPlayerPos[2] + 2.5);
            
TogglePlayerControllable(itrue);
        }
    }
    
// Headroom for static objects - streamed limits are completely independent (cause of old crashing)
    
Streamer_VisibleItems(STREAMER_TYPE_OBJECT958);
}
/*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(playeridnewstateoldstate)
{
    if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        
SetVehicleParamsForPlayer(taxiplayerid01); // lock the doors for the player
    
}
    else
    {
        if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_PASSENGER)
        {
            
SetVehicleParamsForPlayer(taxiplayerid00); // unlock the doors for the player
        
}
    }
    return 
1;

I know the codes are werid thats why i came here.
Reply
#2

Try this:

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if(
vehicleid == taxi && !ispassenger//If he trys to enter the taxi
    
{
        
TogglePlayerControllable(playerid,0);
        
SetTimerEx(!"@uF",200,0,!"i",playerid);
    }
    return 
1;
}
@
uF(i);@uF(i) return TogglePlayerControllable(i,1); 
Reply
#3

Thanks @Kaliber, Its Working efficiently now. Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)