[OnPlayerEnterVehicle] Allowing people to enter faction-restricted car vehicles as passengers only.
#1

Hi everyone, I have faction-restricted vehicles in my server. I'm using OnPlayerEnterVehicle (and no I won't use OnPlayerStateChange on this because I want to prevent players from entering the vehicle before they gets in)

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0) //only driver
    {
        for(new i = 0; i < 37; i++)
    {
            if(vehicleid == LSPD_Vehicles[i])
            {
                if(gTeam[playerid] != LSPD && PlayerInfo[playerid][aLevel] < 3)
                {
                    ClearAnimations(playerid);
                    SendClientMessage(playerid, COLOR_RED, "ERROR: {FFFFFF}You are not in LSPD!");
                }
            }
        }
However, when I'm in other factions (which is not LSPD), I can still enter the vehicle as passenger and driver. How do I fix this?
Reply
#2

Show me how're you setting LSPD_Vehicles
Reply
#3

LSPD Vehicle arrays. Is that you are asking?
Reply
#4

Are you sure youre into the vehicle ID? or the model? Also i think that your looping wrongly, why 37?
Reply
#5

Yes, I'm sure its the vehicle ids. No, I didn't loop wrongly. I have total of 37 LSPD vehicles.

This code actually works before I attempted to code and make so that players could get in as passengers.
I've just added if(ispassenger == 0) //only driver
{
on top, but its a fail.
Reply
#6

I've got this problem two months ago. You'll have to use timers to detect if a player is inside a LSPD Vehicle etc.. OnPlayerEnterVehicle has some bugs so..
Reply
#7

Oh, I see. Well... I guess there isn't any fix for this. I'll try to use the other ways, thank you for your responses everyone.
Reply
#8

It should work if you are doing everything right. Print gteam or everything. You are also checking if the player isnt admin. You maybe forgot that you are admin no?
Reply
#9

Quote:
Originally Posted by Matess
Посмотреть сообщение
It should work if you are doing everything right. Print gteam or everything. You are also checking if the player isnt admin. You maybe forgot that you are admin no?
Oh, wow wtf (facepalm) .___________. I forgot. I didn't realize I have admin level on that account. Thank you for reminding. I'll check it out now and will update about this soon.
Reply
#10

Now I realized the code is actually correct and working. Thanks for your responses guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)