SA-MP Forums Archive
Saving /lock and /unlock - 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: Saving /lock and /unlock (/showthread.php?tid=554084)



Saving /lock and /unlock - Sensation - 02.01.2015

How can I make saving /lock and /unlock system? Please help me..


Re: Saving /lock and /unlock - ATGOggy - 02.01.2015

on top
PHP код:
new doorslocked[MAX_VEHICLES]=0;
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_YELLOW 0xFFFF00AA 
on public OnPlayerCommandText
PHP код:
// /lock
    
if(strcmp(cmdtext"/lock"true20) == 0)
    {
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_ORANGE"ERROR: You are not in any vehicle.");
        if(
GetPlayerState(playerid)==PLAYER_STATE_PASSENGER) return SendClientMessage(playeridCOLOR_ORANGE"ERROR: Only drivers can lock car doors.");
        if(
cardriver[GetPlayerVehicleID(playerid)]==0) return SendClientMessage(playeridCOLOR_ORANGE,"ERROR: You are not in any vehicle.");
        new 
enginelightsalarmdoorsbonnetbootobjective;
        
GetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarmdoorsbonnetbootobjective);
        
SetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarm1bonnetbootobjective);
        
SendClientMessage(playeridCOLOR_YELLOW"Doors locked.");
        
doorslocked[GetPlayerVehicleID(playerid)]=1;
        return 
1;
    }
// /unlock
    
if(strcmp(cmdtext"/unlock"true20) == 0)
    {
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_ORANGE"ERROR: You are not in any vehicle.");
        if(
GetPlayerState(playerid)==PLAYER_STATE_PASSENGER) return SendClientMessage(playeridCOLOR_ORANGE"ERROR: Only drivers can unlock car doors.");
        new 
enginelightsalarmdoorsbonnetbootobjective;
        
GetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarmdoorsbonnetbootobjective);
        
SetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarm0bonnetbootobjective);
        
SendClientMessage(playeridCOLOR_YELLOW"Doors unlocked.");
        
doorslocked[GetPlayerVehicleID(playerid)]=0;
        return 
1;
    } 
on public OnPlayerExitVehicle
PHP код:
    if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
    {
          if(
doorslocked[vehicleid]==1)
        {
             
doorslocked[vehicleid]=0;
            
SendClientMessage(playeridCOLOR_YELLOW"Doors unlocked.");
            new 
enginelightsalarmdoorsbonnetbootobjective;
            
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
            
SetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarm0bonnetbootobjective);
        }

on public OnVehicleStreamIn
PHP код:
    if(doorslocked[vehicleid]==1)
    {
        
SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
    } 
on OnPlayerDisconnect
PHP код:
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
    {
        new 
enginelightsalarmdoorsbonnetbootobjective;
        
GetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarmdoorsbonnetbootobjective);
        
SetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarm0bonnetbootobjective);
        
cardriver[GetPlayerVehicleID(playerid)]=0;
        
doorslocked[GetPlayerVehicleID(playerid)]=0;
    }