01.03.2010, 19:25
Hi, i got a /lock code, that locks car in which player sit, but i want to make that /lock command will work only for player who has his own car.
Код:
if(strcmpEx(cmd, "/lock", true) == 0) { if(VehicleLockedPlayer[playerid] != 999) { SendClientMessage(playerid, COLOR_WHITE, "You must first unlock your previous vehicle."); return 1; } new carid = GetPlayerVehicleID(playerid); if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { if(VehicleLocked[carid] == 0) { if(pStats[playerid][pSex] == 1) { PlayerActionMessage(playerid,15.0,"has just locked his vehicle."); } else { PlayerActionMessage(playerid,15.0,"has just locked her vehicle."); } SendClientMessage(playerid,COLOR_WHITE,"Vehicle Locked."); VehicleLocked[carid] = 1; VehicleLockedPlayer[playerid] = carid; } else { if(pStats[playerid][pSex] == 1) { PlayerActionMessage(playerid,15.0,"has just unlocked his vehicle."); } else { PlayerActionMessage(playerid,15.0,"has just unlocked her vehicle."); } SendClientMessage(playerid,COLOR_WHITE,"Vehicle Unlocked."); VehicleLocked[carid] = 0; VehicleLockedPlayer[playerid] = 999; } } else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { new Float:x,Float:y,Float:z; if(VehicleLockedPlayer[playerid] != 999) { GetVehiclePos(VehicleLockedPlayer[playerid], x, y, z); } if(VehicleLocked[VehicleLockedPlayer[playerid]]) { if(PlayerToPoint(5.0,playerid,x,y,z) || GetPlayerVehicleID(playerid) == VehicleLockedPlayer[playerid]) { if(pStats[playerid][pSex] == 1) { PlayerActionMessage(playerid,15.0,"has just unlocked his vehicle."); } else { PlayerActionMessage(playerid,15.0,"has just unlocked her vehicle."); } SendClientMessage(playerid,COLOR_WHITE,"Vehicle Unlocked."); VehicleLocked[VehicleLockedPlayer[playerid]] = 0; VehicleLockedPlayer[playerid] = 999; } else { SendClientMessage(playerid,COLOR_WHITE,"You're unable to (un)lock your feet."); } } } return 1; }