Saving /lock and /unlock
#1

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)