Making sure it sends the correct message. -
Binx - 22.08.2013
So I've got a dynamic vehicle system but I wanna know how I'd make it send just one message and not ALL 3?
For example, this is my OnPlayerEnterVehicle:
pawn Код:
for(new i = 0; i < MAX_SERVER_VEHICLES; i++)
{
if(VehicleInfo[i][svJob] != PlayerInfo[playerid][pJob] || VehicleInfo[i][svFaction] != PlayerInfo[playerid][pFaction])
{
SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You don't have the keys for this vehicle.");
RemovePlayerFromVehicle(playerid);
}
if(VehicleInfo[i][svJob] != PlayerInfo[playerid][pJob] || VehicleInfo[i][svFaction] == PlayerInfo[playerid][pFaction])
{
SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You don't have the keys for this vehicle.");
RemovePlayerFromVehicle(playerid);
}
if(VehicleInfo[i][svJob] == PlayerInfo[playerid][pJob] || VehicleInfo[i][svFaction] != PlayerInfo[playerid][pFaction])
{
SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You don't have the keys for this vehicle.");
RemovePlayerFromVehicle(playerid);
}
}
This will spam the chat and I don't know how to send it each individually.
For example:
the command is /createvehicle [job] [faction]
So it's detecting whether the players enum equals the vehicles.
So say if it's a faction vehicle, the job would be set to 0.
How would I make it, if the players faction equals the vehicles faction but doesn't equal the vehicles job enum, it'll still let him in the vehicle.
Re: Making sure it sends the correct message. -
JimmyCh - 22.08.2013
What I see from here is that you are getting spammed with 3 messages..
change all || to && and I guess problem is fixed.
Re: Making sure it sends the correct message. -
Binx - 22.08.2013
Quote:
Originally Posted by JimmyCh
What I see from here is that you are getting spammed with 3 messages..
change all || to && and I guess problem is fixed.
|
Wrong, it's because it's in the
however, I don't know how to make it send the each individual message due to the way it's being set out.
Re: Making sure it sends the correct message. -
IceCube! - 22.08.2013
If they all send they all return true... also if their actions are the same why are you even checking... Just do the action.
Re: Making sure it sends the correct message. -
filipkozina - 22.08.2013
Sory sory
moderator delete post , i didnt see what he wont..
Re: Making sure it sends the correct message. -
SuperViper - 22.08.2013
In each check, you need to use
break; at the end to stop the loop.
Re: Making sure it sends the correct message. -
Binx - 22.08.2013
Quote:
Originally Posted by SuperViper
In each check, you need to use break; at the end to stop the loop.
|
So if I did this, would it work properly?
Re: Making sure it sends the correct message. -
IceCube! - 22.08.2013
SuperViper is suggesting something that will work yes but if all 3 are calling, your just going to keep calling if statement 1. If your tring to do this for 1 Vehicle, the one the player is in or near, you need to narrow it down to that vehicle first.