Remove player from vehicle if not his
#1

I'm using vehicle system, when you buy a vehicle it creates a file with your name, what do i have to add to this script below so that it checks if this is your vehicle and if not it removes you?

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"Cars/%s.ini",name);      
    if(dini_Exists(file))
    {

        return 1;
    }
    return 0;
}
Reply
#2

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"Cars/%s.ini",name);      
    if(dini_Exists(file))
    {
        return 1;
    }
    else return RemovePlayerFromVehicle(playerid);
    return 0;
}
Reply
#3

I thought this could work but I get an error

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"Cars/%s.ini",name);
    if(dini_Exists(file))
    {
        new owner[24];
        new veh = GetPlayerVehicleID(playerid);
        GetPlayerName(OwnerID[veh], owner, sizeof(owner));
        if(owner == name)
        {
            SendClientMessage(playerid, COLOR_ORANGE, "Just to test this script (THIS IS YOUR CAR).");
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_ORANGE, "Just to test this script (NOT YOUR CAR).");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
2nd part i want something that will check for this:

JOE enters PAUL's car so it checks in PAUL file for KeyName=JOE and if it exists it allows him to stay, otherwise it removesplayer.
Reply
#4

You need to use strcmp() to compare strings; they aren't the same as variables.
Reply
#5

could you write that line for me
Reply
#6

how can i write that line then so when if(name == owner) ....
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)