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



Vehicle /lock - kbalor - 11.07.2012

EDIT: Can someone add. if a player tries to enter in a locked vehicle a GameTextForPlayer will appear "Vehicle Locked"

Код:
new EnteredVehicle[MAX_PLAYERS], engine, lights, alarm, doors, bonnet, boot, objective;

public OnPlayerStateChange(playerid, newstate, oldstate)
{
     if(newstate == PLAYER_STATE_DRIVER)
     {
            EnteredVehicle[playerid] = GetPlayerVehicleID(playerid);
     }
}

CMD:lock(playerid, params[])
{
     GetVehicleParamsEx(EnteredVehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
     SetVehicleParamsEx(EnteredVehicle[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
     SendClientMessage(playerid, COLOR_GREEN, "Vehicle Locked!");
     return 1;
}
I go 1 error. warning 203: symbol is never used: "lock"


Re: Vehicle /lock - Tuntun - 12.07.2012

it is SendClientMessage(playerid,COLOR_RED,("Vehicles Locked");


Re: Vehicle /lock - clarencecuzz - 12.07.2012

pawn Код:
new EnteredVehicle[MAX_PLAYERS], engine, lights, alarm, doors, bonnet, boot, objective;

public OnPlayerStateChange(playerid, newstate, oldstate)
{
     if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
     {
            EnteredVehicle[playerid] = GetPlayerVehicleID(playerid);
            GetVehicleParamsEx(EnteredVehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors == 1)
            {
                //Remove Player From Vehicle Here
                GameTextForPlayer(playerid, "~r~Vehicle Locked!", 5000, 5);
            }
     }
}

CMD:lock(playerid, params[])
{
     GetVehicleParamsEx(EnteredVehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
     SetVehicleParamsEx(EnteredVehicle[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
     SendClientMessage(playerid, COLOR_GREEN, "Vehicle Locked!");
     return 1;
}
EDIT: Ignore the //Remove Player From Vehicle Here xD


Re: Vehicle /lock - clarencecuzz - 12.07.2012

Actually, I think this function is meant to be used with OnPlayerEnterVehicle...


Re: Vehicle /lock - kbalor - 12.07.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Actually, I think this function is meant to be used with OnPlayerEnterVehicle...
thanks man but i got this error

Код:
warning 203: symbol is never used: "lock"



Re: Vehicle /lock - clarencecuzz - 12.07.2012

Oh lol, put CMD:lock(playerid,params[]) with the rest of the commands.


Re: Vehicle /lock - kbalor - 12.07.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Oh lol, put CMD:lock(playerid,params[]) with the rest of the commands.
thanks man! no errors just need to test ingame. +rep


Re: Vehicle /lock - kbalor - 12.07.2012

Quote:
Originally Posted by kbalor
Посмотреть сообщение
thanks man! no errors just need to test ingame. +rep
GameTextForPlayer(playerid, "~r~Vehicle Locked!", 5000, 5); is not showing after trying to enter to a locked vehicle.


Re: Vehicle /lock - clarencecuzz - 12.07.2012

Just as I thought, should be at OnPlayerEnterVehicle. Give me a second and wait for me to edit this post.


Re: Vehicle /lock - clarencecuzz - 12.07.2012

Replace
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
     if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
     {
            EnteredVehicle[playerid] = GetPlayerVehicleID(playerid);
            GetVehicleParamsEx(EnteredVehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors == 1)
            {
                //Remove Player From Vehicle Here
                GameTextForPlayer(playerid, "~r~Vehicle Locked!", 5000, 5);
            }
     }
}
With:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    EnteredVehicle[playerid] = vehicleid;
    GetVehicleParamsEx(EnteredVehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
    if(doors == 1)
    {
        GameTextForPlayer(playerid, "~r~Vehicle Locked!", 5000, 5);
        return 1;
    }
    return 1;
}
EDIT: Oops, I was meant to edit the other post 0_o :S