31.03.2012, 16:36
To make this fast:
I've created a lock command, which allows a player to lock his vehicle and prevent other players to get in it until the player has unlocked it! Unfortunately, players still can get in:
My second command is the jailcommand, which works fine! But only when the player should get unjailed, he spawns somewhere in the sky! He should get spawned normally:
I've created a lock command, which allows a player to lock his vehicle and prevent other players to get in it until the player has unlocked it! Unfortunately, players still can get in:
pawn Код:
COMMAND:lock(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2 || PlayerInfo[playerid][VIPlevel] >= 2)
{
if(VehicleLocked[playerid] == 1) return SendClientMessage(playerid, COLOR_GREEN, "Your vehicle is already locked!");
if(IsPlayerInAnyVehicle(playerid))
{
VehicleLocked[playerid] = 1;
new name[MAX_PLAYER_NAME], string[ 128 ], string2[ 128 ];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "|| Administrator %s has locked his vehicle! ||", name);
format(string2, sizeof(string2), "|| You have successfully locked your vehicle! ||");
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string2);
}
else return SendClientMessage(playerid, COLOR_RED, "You need to be in a vehicle to lock it!");
}
else return SendClientMessage(playerid, COLOR_RED, "You need to be an level 2 admin or level 2 VIP to use this command!");
return 1;
}
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
//=========================[LOCKING]============================================
VehicleLocked[playerid] = 0;
if(VehicleLocked[playerid] == 1)
{
//new name[MAX_PLAYER_NAME];
//GetPlayerName(playerid, name, sizeof(name));
if(playerid != playerid) return SendClientMessage(playerid, COLOR_RED, "This vehicle has been locked!");
RemovePlayerFromVehicle(playerid);
}
return 1;
}
pawn Код:
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new targetid, minutes;
if(sscanf(params, "ui", targetid, minutes)) return SendClientMessage(playerid, COLOR_RED,"Usage: /jail <playerid> <minutes>");
if(minutes <= 0 || minutes > 60) return SendClientMessage(playerid, COLOR_RED, "Minutes can't be less than 0 or more than 60!");
//if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You can't jail yourself!");
//if(PlayerInfo[targetid][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_RED, "You can't jail higher level admins!");
if(!IsPlayerConnected(targetid))
return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
else
{
new str[128];
format(str, sizeof(str), "Administrator %s has jailed %s for %d minutes!", Name(playerid), Name(targetid), minutes);
SendClientMessageToAll(COLOR_LIGHTBLUE,str);
JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false);
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391);
SetPlayerInterior(targetid, 6);
inJail[targetid] = true;
GameTextForPlayer(targetid, "~p~JAILED", 10000, 6);
PlayerPlaySound(targetid,1057,0.0,0.0,0.0);
}
}
else return SendClientMessage(playerid, COLOR_RED, "You have to be level 4 to use this command!");
return 1;
}
pawn Код:
forward Unjail(playerid);
public Unjail(playerid)
{
SpawnPlayer(playerid);
SetPlayerInterior(playerid, 0);
inJail[playerid] = false;
KillTimer(JailTimer[playerid]);
GameTextForPlayer(playerid, "~g~Unjailed", 5000, 6);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}