if(strcmp(cmd, "/trancar", true) == 0) { if(IsPlayerConnected(playerid)) { new carid; if (gTeam[playerid] == 2 || gTeam[playerid] == 1) { if(gLastCar[playerid] == 0 && PlayerInfo[playerid][pPHousekey] == 255) { SendClientMessage(playerid, COLOR_GRAD2, "Vocк nгo tem um carro de casa/alugado."); return 1; } else if(gLastCar[playerid] != 0 && gLastCar[playerid] != PlayerInfo[playerid][pPHousekey]+totalveiculos) { if (HireCar[playerid] != gLastCar[playerid] && HireCar[playerid] > 0) { gLastDriver[HireCar[playerid]] = 300; VTrancado[HireCar[playerid]] = 0; UnLockCar(HireCar[playerid]); } HireCar[playerid] = gLastCar[playerid]; } } if (PlayerInfo[playerid][pPHousekey] == 255) { if(HireCar[playerid] == 0) { SendClientMessage(playerid, COLOR_GRAD2, "Voce nгo tem um carro."); return 1; } } carid = PlayerInfo[playerid][pPHousekey]+totalveiculosh; if(HireCar[playerid] > 0 && !SwitchKey[playerid]) { carid = HireCar[playerid]; } //new driver = gLastDriver[carid]; new lockstatus = VTrancado[carid]; new Float:cx,Float:cy,Float:cz; GetVehiclePos(carid, cx, cy, cz); switch (lockstatus) { case 0: { if(HireCar[playerid] == 0 && PlayerInfo[playerid][pPHousekey] == 255) { SendClientMessage(playerid, COLOR_GRAD2, "Voce nгo tem um carro"); return 1; } if(HireCar[playerid] == carid && !SwitchKey[playerid]) { GameTextForPlayer(playerid, "~w~Veiculo Alugado~r~Fechado", 5000, 6); PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0); VTrancado[carid] = 1; LockCar(carid); } else if(PlayerInfo[playerid][pPHouseCarkey] == carid) { GameTextForPlayer(playerid, "~w~Veiculo da Casa ~r~Fechado", 5000, 6); PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0); VTrancado[carid] = 1; LockCar(carid); return 1; } } case 1: { if(HireCar[playerid] == 0 && PlayerInfo[playerid][pPHousekey] == 255) { SendClientMessage(playerid, COLOR_GRAD2, "Voce nгo tem um carro"); return 1; } if(HireCar[playerid] == carid && !SwitchKey[playerid]) { GameTextForPlayer(playerid, "~w~Veiculo Alugado~g~Aberto", 5000, 6); PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0); VTrancado[carid] = 0; UnLockCar(carid); SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0); } if (PlayerInfo[playerid][pPHouseCarkey] == carid) { GameTextForPlayer(playerid, "~w~Veiculo da Casa ~g~Aberto", 5000, 6); PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0); VTrancado[carid] = 0; UnLockCar(carid); SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0); return 1; } } default: { SendClientMessage(playerid, COLOR_GRAD2, "Erro"); } } if(carid == 256) { SendClientMessage(playerid, COLOR_GRAD2, "Voce nгo tem um carro!"); } } return 1; }
public LockCar(carid) { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SetVehicleParamsForPlayer(carid,i,0,1); } } }
public UnLockCar(carid) { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SetVehicleParamsForPlayer(carid,i,0,0); } } } encode_tires(tires1, tires2, tires3, tires4) { return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3); }
public LockCar(iCar)
{
for(new i; i < 500; ++i)
{
if(IsPlayerConnected(i))
{
Lock_Car(i);
}
}
return 1;
}
public UnLockCar(carid)
{
for(new i; i < 500; ++)
{
if(IsPlayerConnected(i))
{
Unlock_Car(i);
}
}
return 1;
}
#define Lock_Car(%1) \
SetVehicleParamsForPlayer(GetPlayerVehicleID(%1),%1,0,1)// by iGarfield
#define Unlock_Car(%1) \
SetVehicleParamsForPlayer(GetPlayerVehicleID(%1),%1,0,0) // by iGarfield
tires = encode_tires(1, 1, 1, 1); for(new i; i < 500; ++)
@EDIT: n qrendo ser abusado.. + se alguem postasse algum sisteminha simples d qdo ligar o sv tdos os carros d tdas as casas nascessem trancados.. axo q ficaria mto + facil
|
new Trancado[MAX_VEHICLES];
public OnGameModeInit()
{
for(new c = 0; c < MAX_VEHICLES; c++)
{
Trancado[c] = 1;
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
if(Trancado[GetPlayerVehicleID(playerid)] == 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, -1, "Este veiculo estб trancado.");
return 1;
}
return 1;
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
Trancado[vehicleid] = 0;
return 1;
}
PHP код:
|