locking system
#1

i have a locking code which is:

pawn Код:
CMD:vlock(playerid,params[])
{

    new vid = GetPlayerVehicleID( playerid ), engine, lights, alarm, doors, bonnet, boot, objective;

    GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);

    switch( vDoor[ vid ] )
    {
        case 0: vDoor[ vid ] = 1, SetVehicleParamsEx( vid, engine, lights, alarm, 1, bonnet, boot, objective ), SendClientMessage( playerid, -1, "Doors Locked." );
        default: vDoor[ vid ] = 0, SetVehicleParamsEx( vid, engine, lights, alarm, 0, bonnet, boot, objective ),
SendClientMessage( playerid, -1, "Doors Unlocked." );
    }

    return 1;
}
how would i go about making it so i can lock it and unlock it from the outside because that way only allows me to lock and unlock from the inside
Reply
#2

have it loop through all the vehicles and getting their x, y, z. then it checks
pawn Код:
IsPlayerInRangeOfPoint( playerid, 2, x, y, z);
Reply
#3

pawn Код:
CMD:vlock(playerid,params[])
{

    new vid = GetPlayerVehicleID( playerid ), engine, lights, alarm, doors, bonnet, boot, objective;

    GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);

    switch( vDoor[ vid ] )
    {
        if(IsPlayerInVehicle(playerid, vid); return 0;
        case 0: vDoor[ vid ] = 1, SetVehicleParamsEx( vid, engine, lights, alarm, 1, bonnet, boot, objective ), SendClientMessage( playerid, -1, "Doors Locked." );
        default: vDoor[ vid ] = 0, SetVehicleParamsEx( vid, engine, lights, alarm, 0, bonnet, boot, objective ),
SendClientMessage( playerid, -1, "Doors Unlocked." );
    }

    return 1;
}
Reply
#4

Quote:
Originally Posted by dowster
Посмотреть сообщение
have it loop through all the vehicles and getting their x, y, z. then it checks
pawn Код:
IsPlayerInRangeOfPoint( playerid, 2, x, y, z);
That locks the closest vehicle, regardless if it is yours.

Do this:

pawn Код:
new MyV[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
    MyV[playerid] = -1;
    return 1;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    new vehid =  GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER && vehid  != MyV[playerid]) MyV[playerid] = vehid;
    return 1;
}

CMD:vlock(playerid,params[])
{

    new vid = GetPlayerVehicleID( playerid ), engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(!IsPlayerInAnyVehicle(playerid) && MyV[playerid] != -1)  vid = MyV[playerid];
    switch( vDoor[ vid ] )
    {
        case 0: vDoor[ vid ] = 1, SetVehicleParamsEx( vid, engine, lights, alarm, 1, bonnet, boot, objective ), SendClientMessage( playerid, -1, "Doors Locked." );
        default: vDoor[ vid ] = 0, SetVehicleParamsEx( vid, engine, lights, alarm, 0, bonnet, boot, objective ),
SendClientMessage( playerid, -1, "Doors Unlocked." );
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
That locks the closest vehicle, regardless if it is yours.
true, i didnt type my entire thought, but you would need to see if their in range of it, and then if its theirs. but TheKiller's way is probably better, havent read it yet
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)