14.05.2011, 14:25
Try this
pawn Код:
command(breaklock, playerid, params[])
{
new lockBreakTime;
for(new h; h < MAX_HOUSES; h++) {
if(IsPlayerInRangeOfPoint(playerid, 3.5, HD[h][exteriorX], HD[h][exteriorY], HD[h][exteriorZ])) {
if(HD[h][locklevel] == 0) return SendClientMessage(playerid, COLOR_WHITE, "This house doesn't have a lock!");
lockBreakTime = HD[h][locklevel] * 35 + random(20);
TogglePlayerControllable(playerid, 0);
SetTimerEx("BreakHouseLock", 1000, false, "did", h, playerid, lockBreakTime);
}
if(IsPlayerInRangeOfPoint(playerid, 3.5, HD[h][interiorX], HD[h][interiorY], HD[h][interiorZ]) && GetPlayerInterior(playerid) == HD[h][interiorInt]) {
if(GetPlayerVirtualWorld(playerid) == h) {
if(HD[h][locklevel] == 0) return SendClientMessage(playerid, COLOR_WHITE, "This house doesn't have a lock!");
lockBreakTime = HD[h][locklevel] * 40 + random(20);
TogglePlayerControllable(playerid, 0);
SetTimerEx("BreakHouseLock", 1000, false, "did", h, playerid, lockBreakTime);
}
}
}
return 1;
}
pawn Код:
public BreakHouseLock(houseid, playerid, time)
{
time--;
if(time == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "You broke the lock on the house!");
HD[houseid][locked] = 0;
HD[houseid][locklevel] = 0;
TogglePlayerControllable(playerid, 1);
}
else
{
new string[128];
format(string, sizeof(string), "Breaking Lock~n~%d seconds remaining", time);
GameTextForPlayer(playerid, string, 900, 1);
SetTimerEx("BreakHouseLock", 1000, false, "did", houseid, playerid, time);
}
}