"You cant access this" - Vehicle limitation error -
iPrivate - 17.12.2014
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(playerid);
if(PlayerData[playerid][pFaction] == -1 && VehicleData[vehicle][vFaction] != -1)
{
SendClientMessage(playerid, COLOR_RED, "You can't access this!");
RemovePlayerFromVehicle(playerid);
}
else if(PlayerData[playerid][pFaction] == VehicleData[vehicle][vFaction] && VehicleData[vehicle][vFaction] != -1 && PlayerData[playerid][pFaction] != -1)
{
SendClientMessage(playerid, COLOR_RED, "You can't access this!");
RemovePlayerFromVehicle(playerid);
}
}
That's the code I use right now.
I don't have any clue why it might not work but, this is getting on my nerves. I've tried almost all kind of solutions, NONE will help.
Re: "You cant access this" - Vehicle limitation error -
Glossy42O - 17.12.2014
Is it the full code?
Re: "You cant access this" - Vehicle limitation error -
Dignity - 17.12.2014
pawn Код:
else if(PlayerData[playerid][pFaction] == VehicleData[vehicle][vFaction] && VehicleData[vehicle][vFaction] != -1 && PlayerData[playerid][pFaction] != -1)
If this is to determine the correct faction, why do you kick them from the vehicle? If it isn't, why are you doing this?
Re: "You cant access this" - Vehicle limitation error -
iPrivate - 17.12.2014
If it is a faction vehicle, then they shall get kicked from the car, that's the point, I hope I haven't done a big mess there.
EDIT: I guess I got your point there, but the problem stays that it ain't work. Now all players can join all factions, no limitations.
pawn Код:
if(VehicleData[vehicle][vFaction] != -1 && VehicleData[vehicle][vFaction] != PlayerData[playerid][pFaction])
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(playerid);
if(VehicleData[vehicle][vFaction] != -1 && VehicleData[vehicle][vFaction] != PlayerData[playerid][pFaction])
{
SendClientMessage(playerid, COLOR_RED, "You can't access this!");
RemovePlayerFromVehicle(playerid);
}
}
Re: "You cant access this" - Vehicle limitation error -
Gogorakis - 17.12.2014
Is it MySQL?
Re: "You cant access this" - Vehicle limitation error -
Dignity - 17.12.2014
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(playerid);
if(VehicleData[vehicle][vFaction] != -1 || VehicleData[vehicle][vFaction] != PlayerData[playerid][pFaction])
{
SendClientMessage(playerid, COLOR_RED, "You can't access this!");
RemovePlayerFromVehicle(playerid);
}
}
The way your code works, the message would only be sent if the vehicle faction was -1, AND the vehicle faction wasn't the same as a player's faction ID. (Since you used &&, which means 'and').
I changed it to '||', which is or.
Try my code.
Re: "You cant access this" - Vehicle limitation error -
iPrivate - 17.12.2014
It wont work yet. I have tried that before. By the way, I forgot to say that these cars are able to be driven by people who are in factions. For example, if I am in faction, I am able to drive all these cars.
Just when I quit faction, I'm not able to drive them anymore.
Re: "You cant access this" - Vehicle limitation error -
Dignity - 17.12.2014
Why not do something like this?
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(playerid);
// If they aren't in the right faction...
if(VehicleData[vehicle][vFaction] != PlayerData[playerid][pFaction])
{
SendClientMessage(playerid, COLOR_RED, "You can't access this!");
RemovePlayerFromVehicle(playerid);
}
// If they are in the right faction...
else return SendClientMessage(playerid, COLOR_RED, "Welcome to your faction's vehicle!");
}
Re: "You cant access this" - Vehicle limitation error -
iPrivate - 18.12.2014
That ain't work either. I made it kinda easier (less complicated) by just using the vehicle model, but wont work either.
pawn Код:
if(GetVehicleModel(vehicle) == 596 || GetVehicleModel(vehicle) == 599 || GetVehicleModel(vehicle) == 601 && PlayerData[playerid][pFaction] != 1)
{
SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle.");
RemovePlayerFromVehicle(playerid);
}
Re: "You cant access this" - Vehicle limitation error -
Dignity - 18.12.2014
How does it not work? Also, your code is flawed as it will basically allow anyone who has a faction ID higher than -1 to drive in the vehicles you listed.
I'm all out of ideas. Try to change this line:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
to
pawn Код:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
If my code doesn't work, something else is causing this issue.
Quote:
Originally Posted by Meller
Test this
Код:
if(GetVehicleModel(vehicle) == 596
{
SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle.");
RemovePlayerFromVehicle(playerid);
}
|
Do you even know what your code does?