Vehicle Ownership - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle Ownership (
/showthread.php?tid=413053)
Vehicle Ownership -
Ld Est Ld - 03.02.2013
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.
Respuesta: Vehicle Ownership -
Strier - 03.02.2013
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 ?
Re: Vehicle Ownership -
Ld Est Ld - 04.02.2013
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.
Re : Vehicle Ownership -
lelemaster - 04.02.2013
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;
}
Re: Vehicle Ownership -
Ld Est Ld - 04.02.2013
well, two debugging pictures.
Re: Vehicle Ownership -
Ld Est Ld - 04.02.2013
Fixed.
Thank You for trying to help.
THe prolem was in the loop. Please close this.