Fast array question
#1

Hey guys.
Just a fast question on arrays.
I added 4 vehicles, that only some people can use (People who has mechanic job).
I added the vehicles like this:
pawn Код:
new mechanicvehicles[4]; // Because there are 4 vehicles
and in OnPlayerEnterVehicle:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(PlayerInfo[playerid][pJob] != 1)
    {
        if(vehicleid == mechanicvehicles[playerid])
        {
            SetPlayerPos(playerid, x, y, z);
            SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) Only Mechanics can use This Vehicle");
        }
    }
    return 1;
}
But this only ejects the player from one of the vehicles. I want it to happend on all 4 vehicles.
The problem is in this line:
pawn Код:
if(vehicleid == mechanicvehicles[playerid])
But i dont know what else to write.

Thank you.
Reply
#2

And by the way i also did this in OnGameModeInit:
pawn Код:
mechanicvehicles[0] = AddStaticVehicle(525,2080.1189,-2006.5361,13.4202,270.0635,22,30); // mechaniccar1
mechanicvehicles[1] = AddStaticVehicle(552,2080.4067,-2019.9713,13.2515,268.8202,56,56); // mechaniccar2
mechanicvehicles[2] = AddStaticVehicle(525,2080.2844,-2033.1355,13.4281,271.6693,44,51); // mechaniccar3
mechanicvehicles[3] = AddStaticVehicle(552,2080.0762,-2046.6104,13.2434,269.6772,26,124); // mechaniccar4
Reply
#3

pawn Код:
if(vehicleid == mechanicvehicles[MAX_PLAYERS])
I guess this will do it
Reply
#4

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
pawn Код:
if(vehicleid == mechanicvehicles[MAX_PLAYERS])
I guess this will do it
Thank you. Ill try.
Reply
#5

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(PlayerInfo[playerid][pJob] != 1)
    {
        for(new i=0; i<sizeof(mechanicvehicles); i++)
        {
            if(vehicleid == mechanicvehicles[i])
            {
                SetPlayerPos(playerid, x, y, z);
                SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) Only Mechanics can use This Vehicle");
                break;
            }
        }  
    }
    return 1;
}
Reply
#6

*sigh* Dumb_answers_of_the_day++;
Edit: I'm slow again. That was directed at Wesley221

pawn Код:
if(PlayerInfo[playerid][pJob] != 1)
    {
        for(new i; i < sizeof(mechanicvehicles); i++)
        {
            if(mechanicvehicles[i] == vehicleid)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) Only Mechanics can use This Vehicle");
                break;
            }
        }
    }
Reply
#7

Quote:
Originally Posted by Dreftas
Посмотреть сообщение
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(PlayerInfo[playerid][pJob] != 1)
    {
        for(new i=0; i<sizeof(mechanicvehicles); i++)
        {
            if(vehicleid == mechanicvehicles[i])
            {
                SetPlayerPos(playerid, x, y, z);
                SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) Only Mechanics can use This Vehicle");
                break;
            }
        }  
    }
    return 1;
}
Thank you. Ill try
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)