Vehicle /lock
#1

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"
Reply
#2

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

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
Reply
#4

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

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"
Reply
#6

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

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
Reply
#8

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.
Reply
#9

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)