if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] != vehicleid)
if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] == vehicleid)
new PlayerCar[MAX_PLAYERS], LockedCar[1000];
new Text:Locked;
new MsgLocked[MAX_PLAYERS], LockedTimer[MAX_PLAYERS];
forward RemoveLock(playerid);
public OnPlayerConnect(playerid)
{
PlayerCar[playerid] = -1;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/lock", true))
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); // player has to be in a vehicle
if(GetPlayerVehicleSeat(playerid) != 0)
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver."); // player has to be a driver
if(PlayerCar[playerid] != -1)
{
LockedCar[PlayerCar[playerid]] = 0; // if player has any locked vehicle it will unlock it, allowing him to lock current vehicle - every player can have only one locked vehicle
}
PlayerCar[playerid] = GetPlayerVehicleID(playerid); // bounds vehicle to a player
LockedCar[GetPlayerVehicleID(playerid)] = 1; // locks vehicle
return 1;
}
if(!strcmp(cmdtext, "/unlock", true))
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
if(GetPlayerVehicleSeat(playerid) != 0)
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver.");
PlayerCar[playerid] = -1; // tells server that this player don't have any locked vehicle
LockedCar[GetPlayerVehicleID(playerid)] = 0; // unlocks current vehicle
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] != vehicleid) // if player is trying to enter locked vehicle and he is not bound to that vehicle
{
if(MsgLocked[playerid] == 1) // if there's already message showing for player
{
TextDrawHideForPlayer(playerid, Locked); // hides message
MsgLocked[playerid] = 0; // there's no more any message regarding locked car
KillTimer(LockedTimer[playerid]); // kills timer
}
TogglePlayerControllable(playerid, true); // stops player from entering vehicle (it's not his vehicle, why should he enter it?)
Locked = TextDrawCreate(10.0, 250.0, "This Vehicle is Locked"); // pretty much self-explanatory
TextDrawUseBox(Locked, 1);
TextDrawBoxColor(Locked, 0x00000055);
TextDrawTextSize(Locked, 125, 5);
TextDrawShowForPlayer(playerid, Locked); // shows TextDraw to player
LockedTimer[playerid] = SetTimer("RemoveLock", 4000, false); // sets timer for hiding TextDraw
MsgLocked[playerid] = 1; // we have TextDraw showing
}
return 1;
}
public RemoveLock(playerid)
{
if(MsgLocked[playerid] == 1) // if there's message showing for player
{
TextDrawHideForPlayer(playerid, Locked); // hides message
MsgLocked[playerid] = 0; // there's no more any message regarding locked car
}
}
public OnVehicleSpawn(vehicleid)
{
LockedCar[vehicleid] = 0; // when vehicle has respawned (nobody has entered it for a while) server will unlock it
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerCar[i] == vehicleid)
PlayerCar[i] = -1; // unbounds player from this vehicle so anyone can enter it
}
return 1;
}
new PlayerCar[MAX_PLAYERS], LockedCar[1000];
new Text:Locked;
new MsgLocked[MAX_PLAYERS], LockedTimer[MAX_PLAYERS];
forward RemoveLock(playerid);
public OnPlayerConnect(playerid)
{
PlayerCar[playerid] = -1;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/lock", true))
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); // player has to be in a vehicle
if(GetPlayerVehicleSeat(playerid) != 0)
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver."); // player has to be a driver
if(PlayerCar[playerid] != -1)
{
LockedCar[PlayerCar[playerid]] = 0; // if player has any locked vehicle it will unlock it, allowing him to lock current vehicle - every player can have only one locked vehicle
}
PlayerCar[playerid] = GetPlayerVehicleID(playerid); // bounds vehicle to a player
LockedCar[GetPlayerVehicleID(playerid)] = 1; // locks vehicle
return 1;
}
if(!strcmp(cmdtext, "/unlock", true))
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
if(GetPlayerVehicleSeat(playerid) != 0)
return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver.");
PlayerCar[playerid] = -1; // tells server that this player don't have any locked vehicle
LockedCar[GetPlayerVehicleID(playerid)] = 0; // unlocks current vehicle
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] != vehicleid) // if player is trying to enter locked vehicle and he is not bound to that vehicle
{
if(MsgLocked[playerid] == 1) // if there's already message showing for player
{
TextDrawHideForPlayer(playerid, Locked); // hides message
MsgLocked[playerid] = 0; // there's no more any message regarding locked car
KillTimer(LockedTimer[playerid]); // kills timer
}
TogglePlayerControllable(playerid, true); // stops player from entering vehicle (it's not his vehicle, why should he enter it?)
Locked = TextDrawCreate(10.0, 250.0, "This Vehicle is Locked"); // pretty much self-explanatory
TextDrawUseBox(Locked, 1);
TextDrawBoxColor(Locked, 0x00000055);
TextDrawTextSize(Locked, 125, 5);
TextDrawShowForPlayer(playerid, Locked); // shows TextDraw to player
LockedTimer[playerid] = SetTimer("RemoveLock", 4000, false); // sets timer for hiding TextDraw
MsgLocked[playerid] = 1; // we have TextDraw showing
}
return 1;
}
public RemoveLock(playerid)
{
if(MsgLocked[playerid] == 1) // if there's message showing for player
{
TextDrawHideForPlayer(playerid, Locked); // hides message
MsgLocked[playerid] = 0; // there's no more any message regarding locked car
}
}
public OnVehicleSpawn(vehicleid)
{
LockedCar[vehicleid] = 0; // when vehicle has respawned (nobody has entered it for a while) server will unlock it
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerCar[i] == vehicleid)
PlayerCar[i] = -1; // unbounds player from this vehicle so anyone can enter it
}
return 1;
}
see:
F:\test.pwn(4) : error 017: undefined symbol "LockedCar" F:\test.pwn(4) : warning 215: expression has no effect F:\test.pwn(4) : error 001: expected token: ";", but found "]" F:\test.pwn(4) : error 029: invalid expression, assumed zero F:\test.pwn(4) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors. |
#include <a_samp> public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] != vehicleid) { if(MsgLocked[playerid] == 1) { TextDrawHideForPlayer(playerid, Locked); MsgLocked[playerid] = 0; KillTimer(LockedTimer[playerid]); } TogglePlayerControllable(playerid, true); Locked = TextDrawCreate(10.0, 250.0, "This Vehicle is Locked"); TextDrawUseBox(Locked, 1); TextDrawBoxColor(Locked, 0x00000055); TextDrawTextSize(Locked, 125, 5); TextDrawShowForPlayer(playerid, Locked); / LockedTimer[playerid] = SetTimer("RemoveLock", 4000, false); MsgLocked[playerid] = 1; } return 1; } public RemoveLock(playerid) { if(MsgLocked[playerid] == 1) { TextDrawHideForPlayer(playerid, Locked); MsgLocked[playerid] = 0; } } public OnVehicleSpawn(vehicleid) { LockedCar[vehicleid] = 0; for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerCar[i] == vehicleid) PlayerCar[i] = -1; } return 0; }
Код:
#include <a_samp> public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] != vehicleid) { if(MsgLocked[playerid] == 1) { TextDrawHideForPlayer(playerid, Locked); MsgLocked[playerid] = 0; KillTimer(LockedTimer[playerid]); } TogglePlayerControllable(playerid, true); Locked = TextDrawCreate(10.0, 250.0, "This Vehicle is Locked"); TextDrawUseBox(Locked, 1); TextDrawBoxColor(Locked, 0x00000055); TextDrawTextSize(Locked, 125, 5); TextDrawShowForPlayer(playerid, Locked); / LockedTimer[playerid] = SetTimer("RemoveLock", 4000, false); MsgLocked[playerid] = 1; } return 1; } public RemoveLock(playerid) { if(MsgLocked[playerid] == 1) { TextDrawHideForPlayer(playerid, Locked); MsgLocked[playerid] = 0; } } public OnVehicleSpawn(vehicleid) { LockedCar[vehicleid] = 0; for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerCar[i] == vehicleid) PlayerCar[i] = -1; } return 0; } |
Try this: if((LockedCar[vehicleid] == 1) && (PlayerCar[playerid] != vehicleid))
|
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (vehicleid == some_id)
{
SendClientMessage(playerid, -1, "GTFO");
ClearAnimations(playerid);
}
}