Vehicle Ownership
#1

Hello.

I have a one problem, that i can't figure it out. Tried any different ways for hours and still no results.

What I'm planning to do is a vehicle ownership, where 1 player owns a car and another player can't start the machine without the keys.

Well, I have ownership, but what I can't figure out, how to make like player can start their own machine only

pawn Код:
//function
getPlayerVID(playerid) {
    new
        x;

    while(x < MAX_VEHICLES) {
        if(playerVehicleVariables[x][pVehicleOwner] >= 1) {
            if(playerVehicleVariables[x][pVehicleOwner] == playerVariables[playerid][pInternalID]) {
                return x;
            }
        }
        x++;
    }

    return 0;
}

//for starting machine
if(getPlayerVID(playerid) >= 1) {
        allowed= 1;
    } else {
        allowed= 0;
    }
This works like this right now:
If I don't have a car, and I'm trying to start someone else's vehicle, then I can't do it. Says: You don't have the keys.
If I have my own vehicle, I can start whoever's vehicle.
Reply
#2

pawn Код:
if(getPlayerVID(playerid) >= 1) {
        SendClientMessage(playerid, -1, "Engine started");
        allowed= 1;
    } else {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x-3,y,z);
        SendClientMessage(playerid, -1, "You don't have the key to drive this vehicle");
        allowed= 0;
    }
i think this would work ?
Reply
#3

THanks for your reply, but.

This works like this right now:
If I don't have a car, and I'm trying to start someone else's vehicle, then I can't do it. Says: You don't have the keys.
If I have my own vehicle, I can start whoever's vehicle.


I think it's something wrong in loop, but i don't know, what it is.
Reply
#4

Then try this:

pawn Код:
if(getPlayerVID(playerid) == GetPlayerVehicleID(playerid)) {
        SendClientMessage(playerid, -1, "Engine started");
        allowed= 1;
    } else {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x-3,y,z);
        SendClientMessage(playerid, -1, "You don't have the key to drive this vehicle");
        allowed= 0;
    }
Reply
#5

well, two debugging pictures.

Reply
#6

Fixed.

Thank You for trying to help.

THe prolem was in the loop. Please close this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)