06.05.2013, 10:14
Hi, I am trying to get this command to work. It works inside the car but outside the car it doesnt seem to work.
pawn Код:
CMD:carlock(playerid, params[])
{
if(!isnull(params)) return SystemMsg(playerid, "Use /carlock");
// if(!IsPlayerInAnyVehicle(playerid)) return SystemMsg(playerid, "You must be in your vehicle.");
new playerstate = GetPlayerState(playerid);
if(playerstate == PLAYER_STATE_DRIVER && playerstate != PLAYER_STATE_ONFOOT)
{
if(GetPlayerVehicleSeat(playerid) != 0) return SystemMsg(playerid, "You must be in the drivers seat to lock or unlock the vehicle.");
new vid = GetPlayerVehicleID(playerid);
new PlayerName[24];
GetPlayerName(playerid, PlayerName, 24);
if(!PlayerOwnsVehicle(PlayerName, vid)) return SystemMsg(playerid, "You can only lock your own vehicles.");
if(CarLocked(vid))
{
new loc[25];
format(loc, sizeof(loc), "/Vehicles/%i.ini", FileID[vid]);
dini_IntSet(loc, "Locked", 0);
SendClientMessage(playerid, COLOR_SKY, "You unlocked your vehicle.");
}
else
{
new loc[25];
format(loc, sizeof(loc), "/Vehicles/%i.ini", FileID[vid]);
dini_IntSet(loc, "Locked", 1);
SendClientMessage(playerid, COLOR_SKY, "You locked your vehicle.");
}
}
if(playerstate == PLAYER_STATE_ONFOOT)
{
new vid = GetPlayerVehicleID(playerid);
new Float:pX,Float:pY,Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
new Float:vX,Float:vY,Float:vZ;
new Found=0;
vid=0;
while((vid<MAX_VEHICLES)&&(!Found))
{
vid++;
GetVehiclePos(vid,vX,vY,vZ);
new PlayerName[24];
GetPlayerName(playerid, PlayerName, 24);
if ((floatabs(pX-vX)<4.0)&&(floatabs(pY-vY)<4.0)&&(floatabs(pZ-vZ)<4.0) && PlayerOwnsVehicle(PlayerName, vid))
{
if(CarLocked(vid))
{
new loc[25];
format(loc, sizeof(loc), "/Vehicles/%i.ini", FileID[vid]);
dini_IntSet(loc, "Locked", 0);
SendClientMessage(playerid, COLOR_SKY, "You unlocked your vehicle.");
}
else
{
new loc[25];
format(loc, sizeof(loc), "/Vehicles/%i.ini", FileID[vid]);
dini_IntSet(loc, "Locked", 1);
SendClientMessage(playerid, COLOR_SKY, "You locked your vehicle.");
}
} else return SystemMsg(playerid, "You can only lock your own car.");
} }
return 1;
}