Making sure it sends the correct message.
#1

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.
Reply
#2

What I see from here is that you are getting spammed with 3 messages..
change all || to && and I guess problem is fixed.
Reply
#3

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
Код:
for(new ...)
however, I don't know how to make it send the each individual message due to the way it's being set out.
Reply
#4

If they all send they all return true... also if their actions are the same why are you even checking... Just do the action.
Reply
#5

Sory sory

moderator delete post , i didnt see what he wont..
Reply
#6

In each check, you need to use break; at the end to stop the loop.
Reply
#7

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?
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)