SA-MP Forums Archive
locking system - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: locking system (/showthread.php?tid=272334)



locking system - slymatt - 28.07.2011

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


Re: locking system - dowster - 28.07.2011

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



Re: locking system - TheArcher - 28.07.2011

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;
}



Re: locking system - [HiC]TheKiller - 28.07.2011

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;
}



Re: locking system - dowster - 28.07.2011

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