SA-MP Forums Archive
Help with restricting - 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: Help with restricting (/showthread.php?tid=439702)



Help with restricting - Dare Devil..... - 26.05.2013

Can I do something that if a person enters the car id 597 and he is not a Guard, he should be automaticly ejected from it but if he is sitting on any other seat except driving he can sit there.

I use this under commands which I spesify for guards only

pawn Код:
if(!(PlayerInfo[playerid][pGuard] == 1)) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
        if(PlayerInfo[playerid][pGuard] == 1)
Immediate help required tell me if you need any other code.


Re: Help with restricting - DaRk_RaiN - 26.05.2013

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && PlayerInfo[playerid][pGuard] == 1)
    {
        new vehicleid = GetPlayerVehicleID( playerid );
        if(GetVehicleModel(vehicleid) == 597)
        {
            RemovePlayerFromVehicle(playerid);
            ClearAnimations(playerid);
            SCM(playerid, COLOR_GREY,"You are not authorized to sit your ass in there");
        }
    }
    return 1;
}



Re: Help with restricting - IceBilizard - 26.05.2013

pawn Код:
if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
 if(GetVehicleModel(vehicleid) == 597 && PlayerInfo[playerid][pGuard] != 1) return RemovePlayerFromVehicle(playerid);
 SCM(playerid, COLOR_GREY,"You are not authorized to use this Vehicle");   
}



Re: Help with restricting - Dare Devil..... - 26.05.2013

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)

{
//==================================DEALERSHIP=====================================
    if(IsPlayerInAnyVehicle(playerid) && !IsBicycle(GetPlayerVehicleID(playerid)))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(VehicleSecurity[vehicleid] == 1)
        {
            ToggleAlarm(vehicleid, VEHICLE_PARAMS_ON);
            SetTimerEx("StopAlarm", ALARM_TIME, false, "d", vehicleid);
        }
    }
    else
    {
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new car = GetPlayerVehicleID(playerid);
        if(car == dmvc || car == dmvc1 || car == dmvc2)
        {
            SCM(playerid, COLOR_GOLD,"Type /dmvtest to start the Drivers License test or /exitcar to exit");
        }
        else
        {
            if(PlayerInfo[playerid][pDriveLic] < 1)
            {
                SendClientMessage(playerid, COLOR_GREEN, "You need a driving license, Other wise Guards with catch you.");
                TogglePlayerControllable(playerid, 0);
                SetTimer("Unfreeze", 2000, 0);
            }
        }
        new vehicleid = GetPlayerVehicleID(playerid);
        new id = GetVehicleID(vehicleid);
        if(IsValidVehicle(id))
        {
            if(VehicleCreated[id] == VEHICLE_DEALERSHIP)
            {
                SetPVarInt(playerid, "DialogValue1", id);
                ShowDialog(playerid, DIALOG_VEHICLE_BUY);
                return 1;
            }
        }
        if(IsBicycle(vehicleid))
        {
            ToggleEngine(vehicleid, VEHICLE_PARAMS_ON);
        }
        if(Fuel[vehicleid] <= 0)
        {
            ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
        }
//=======================================ENGINE=================================
        if(vehEngine[vehicleid] == 0)
        {
            TogglePlayerControllable(playerid, 0);
            SendClientMessage(playerid, COLOR_GOLD, "Type /engine to turn the vehicle on.");
        }
        else if(vehEngine[vehicleid] == 1)
        {
            TogglePlayerControllable(playerid, 1);
            SendClientMessage(playerid, COLOR_GREEN, "Vehicle engine running");
        }
    }
 
    return 1;
}
I got this already there when I put that code under it it gives up a bunch of errors


Re: Help with restricting - DaRk_RaiN - 26.05.2013

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && PlayerInfo[playerid][pGuard] == 1)
    {
        new vehicleid = GetPlayerVehicleID( playerid );
        if(GetVehicleModel(vehicleid) == 597)
        {
            RemovePlayerFromVehicle(playerid);
            ClearAnimations(playerid);
            SCM(playerid, COLOR_GREY,"You are not authorized to sit your ass in there");
        }
    }
//==================================DEALERSHIP=====================================
    if(IsPlayerInAnyVehicle(playerid) && !IsBicycle(GetPlayerVehicleID(playerid)))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(VehicleSecurity[vehicleid] == 1)
        {
            ToggleAlarm(vehicleid, VEHICLE_PARAMS_ON);
            SetTimerEx("StopAlarm", ALARM_TIME, false, "d", vehicleid);
        }
    }
    else
    {
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new car = GetPlayerVehicleID(playerid);
        if(car == dmvc || car == dmvc1 || car == dmvc2)
        {
            SCM(playerid, COLOR_GOLD,"Type /dmvtest to start the Drivers License test or /exitcar to exit");
        }
        else
        {
            if(PlayerInfo[playerid][pDriveLic] < 1)
            {
                SendClientMessage(playerid, COLOR_GREEN, "You need a driving license, Other wise Guards with catch you.");
                TogglePlayerControllable(playerid, 0);
                SetTimer("Unfreeze", 2000, 0);
            }
        }
        new vehicleid = GetPlayerVehicleID(playerid);
        new id = GetVehicleID(vehicleid);
        if(IsValidVehicle(id))
        {
            if(VehicleCreated[id] == VEHICLE_DEALERSHIP)
            {
                SetPVarInt(playerid, "DialogValue1", id);
                ShowDialog(playerid, DIALOG_VEHICLE_BUY);
                return 1;
            }
        }
        if(IsBicycle(vehicleid))
        {
            ToggleEngine(vehicleid, VEHICLE_PARAMS_ON);
        }
        if(Fuel[vehicleid] <= 0)
        {
            ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
        }
//=======================================ENGINE=================================
        if(vehEngine[vehicleid] == 0)
        {
            TogglePlayerControllable(playerid, 0);
            SendClientMessage(playerid, COLOR_GOLD, "Type /engine to turn the vehicle on.");
        }
        else if(vehEngine[vehicleid] == 1)
        {
            TogglePlayerControllable(playerid, 1);
            SendClientMessage(playerid, COLOR_GREEN, "Vehicle engine running");
        }
    }

    return 1;
}