Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Car jack/stealing detector.

 
  • 0 Vote(s) - 0 Average
Pawn Car jack/stealing detector.
Ambarita
Offline

Burgershot Member
Posts: 6
Threads: 3
Joined: Apr 2021
Reputation: 0
#1
2021-07-20, 12:10 AM
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?
Next
Offline

Burgershot Member
Posts: 2
Threads: 1
Joined: Aug 2019
Reputation: 0
#2
2021-07-20, 01:39 AM (This post was last modified: 2021-07-20, 01:42 AM by Next.)
This can help:

PHP Code:
IsVehicleOccupied(vehicleid)
{
    for(new i = GetPlayerPoolSize(); i != -1; i--) 
        
if(IsPlayerInVehicle(i, vehicleid) && GetPlayerVehicleSeat(i) == 0)
            return 1;

    return 0;
} 

can use foreach too.
daddy.
Offline

Burgershot Member
Posts: 58
Threads: 7
Joined: Nov 2019
Reputation: 3
Location: Bosnia and Herzegovina / Zenica
#3
2021-07-22, 01:58 PM
There already is 'IsVehicleOccupied' native in YSF, use that one.
https://github.com/IllidanS4/YSF
daddy. / daddyDOT
https://github.com/daddyDOT

♥
[Image: image.png]
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#4
2021-07-22, 09:13 PM (This post was last modified: 2021-07-22, 09:19 PM by Pinch.)
(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
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
daddy.
Offline

Burgershot Member
Posts: 58
Threads: 7
Joined: Nov 2019
Reputation: 3
Location: Bosnia and Herzegovina / Zenica
#5
2021-07-23, 09:19 PM
(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
daddy. / daddyDOT
https://github.com/daddyDOT

♥
[Image: image.png]
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode