open.mp forum
[Pawn] Car jack/stealing detector. - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Car jack/stealing detector. (/showthread.php?tid=2184)



Car jack/stealing detector. - Ambarita - 2021-07-20

So I want to make an admin warning message if a player car jack/steal a vehicle that is being occupied by someone.



Is there a function to check if the vehicle is occupied? or maybe a function that would help me make this code.



If not, any idea that would help me?


RE: Car jack/stealing detector. - Next - 2021-07-20

This can help:



PHP Code:
IsVehicleOccupied(vehicleid)

{

? ? for(new 
GetPlayerPoolSize(); != -1i--)?

? ? ? ? if(
IsPlayerInVehicle(ivehicleid) && GetPlayerVehicleSeat(i) == 0)

? ? ? ? ? ? return 
1;



? ? return 
0;





can use foreach too.


RE: Car jack/stealing detector. - daddy. - 2021-07-22

There already is 'IsVehicleOccupied' native in YSF, use that one.

https://github.com/IllidanS4/YSF


RE: Car jack/stealing detector. - Pinch - 2021-07-22

(2021-07-22, 01:58 PM)daddy. Wrote: There already is 'IsVehicleOccupied' native in YSF, use that one.
https://github.com/IllidanS4/YSF
...which does the exact same thing with even more checks checks if player is either driver or passenger so they would need a extra check there :)

EDIT: But for some odd reason, YSF also has HasVehicleBeenOccupied which is much more efficient check as it does not run loops, wtf Illidan XD
EDIT 2: This actually might not work, wtf xD


RE: Car jack/stealing detector. - daddy. - 2021-07-23

(2021-07-22, 09:13 PM)Pinch Wrote:
(2021-07-22, 01:58 PM)daddy. Wrote: There already is 'IsVehicleOccupied' native in YSF, use that one.

https://github.com/IllidanS4/YSF

...which does the exact same thing with even more checks checks if player is either driver or passenger so they would need a extra check there :)



True, fair enough to quote :D