Make a vehicle theft wanted system
#1

Hi!



Are there any easy way to create a vehicle wanted system?..

I mean if you steal a car you get wanted, that I have fixed so far...


But are there any good way so I can detect if the person already stole a vehicle
and enter the stolen vehicle again I don't want the player to get wanted again..

Any suggestions? (Easy way....)
Reply
#2

One was created, I don't know if it still works, could give it a go: https://sampforum.blast.hk/showthread.php?tid=278082. Use some global vars to detect if the player has already stolen a car too, like:

pawn Код:
new stolen[MAX_PLAYERS];

public OnPlayerConnect(playerid);
{
     stolen = 0;
     return 1;
}

public OnPlayerJackVehicle(playerid,victimid,vehicleid,bool:ninjajack)
{
     if(stolen == 1) return 1;
     // personal code here
     stolen = 1;
     return 1;
}
Reply
#3

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
One was created, I don't know if it still works, could give it a go: https://sampforum.blast.hk/showthread.php?tid=278082. Use some global vars to detect if the player has already stolen a car too, like:

pawn Код:
new stolen[MAX_PLAYERS];

public OnPlayerConnect(playerid);
{
     stolen = 0;
     return 1;
}

public OnPlayerJackVehicle(playerid,victimid,vehicleid,bool:ninjajack)
{
     if(stolen == 1) return 1;
     // personal code here
     stolen = 1;
     return 1;
}
Thanks a lot but I thought of parked vehicles, forgot to mention that sorry
Reply
#4

How do you want to check if a vehicle is parked? The only way to do so, is giving every vehicle ID a variable (e.g. vParked[vehid]) on spawn of the vehicle. Once a player enters the car, set the variable to 0 (or whatever you desire).. If you know how your personal vehicle engine works, you could easily do this..

Anyway, if you're going to use my method, you could use this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vParked[vehicleid] == 1) // if the vehicle is parked
    {
        vParked[vehicleid] = 0; // Make sure the vehicle is no longer parked
        SetPlayerWantedLevel(playerid, 1); //This adds one star
    }
    return 1;
}
If you want the vehicle to get parked again, you could create a command "/parkvehicle" and set the vParked variable to 1. Or you could do this automatically once the player exits the car (OnPlayerExitVehicle).
Reply
#5

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
How do you want to check if a vehicle is parked? The only way to do so, is giving every vehicle ID a variable (e.g. vParked[vehid]) on spawn of the vehicle. Once a player enters the car, set the variable to 0 (or whatever you desire).. If you know how your personal vehicle engine works, you could easily do this..

Anyway, if you're going to use my method, you could use this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vParked[vehicleid] == 1) // if the vehicle is parked
    {
        vParked[vehicleid] = 0; // Make sure the vehicle is no longer parked
        SetPlayerWantedLevel(playerid, 1); //This adds one star
    }
    return 1;
}
If you want the vehicle to get parked again, you could create a command "/parkvehicle" and set the vParked variable to 1. Or you could do this automatically once the player exits the car (OnPlayerExitVehicle).
Hmm won't it happen to every vehicle then?

If I steal some vehicle and I dump it, then steal another vehicle won't I get a
wanted level then?..

Because I just want it if you steal a vehicle you get wanted
and then when you enter it again I don't want to get a wanted level again..

(Like it is in singleplayer)
You are allowed to take same car again after you stole it if you have it for a while..

Do you know how they have done on other servers?
Reply
#6

Quote:
Originally Posted by davve95
Посмотреть сообщение
Hmm won't it happen to every vehicle then?

If I steal some vehicle and I dump it, then steal another vehicle won't I get a
wanted level then?..

Because I just want it if you steal a vehicle you get wanted
and then when you enter it again I don't want to get a wanted level again..

(Like it is in singleplayer)
You are allowed to take same car again after you stole it if you have it for a while..
You choose which vehicle ids will get this parked variable yourself.
If any person enters this vehicle after it has been stolen, they will not get a wanted level (only the first one who actually stole the car). The vehicle is no longer parked after it has been "stolen". The code is also not as advanced as you wish. But I'm here to help you so you can do it by yourself. I'm not here to give you a filterscript.
Quote:
Originally Posted by davve95
Посмотреть сообщение
Do you know how they have done on other servers?
No, I don't play SA-MP servers
Reply
#7

Quote:
Originally Posted by davve95
Посмотреть сообщение
Hmm won't it happen to every vehicle then?

If I steal some vehicle and I dump it, then steal another vehicle won't I get a
wanted level then?..

Because I just want it if you steal a vehicle you get wanted
and then when you enter it again I don't want to get a wanted level again..

(Like it is in singleplayer)
You are allowed to take same car again after you stole it if you have it for a while..

Do you know how they have done on other servers?
You could check the player's wanted level, if he has more than or 1 wanted level, return it by 0

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vParked[vehicleid] == 1)
        return vParked[vehicleid] = 0, SetPlayerWantedLevel(playerid, 1);
   
    if(GetPlayerWantedLevel(playerid) >= 1 && vParked[vehicleid] == 1) return 0;
    return 1;
}
Reply
#8

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
You could check the player's wanted level, if he has more than or 1 wanted level, return it by 0

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vParked[vehicleid] == 1)
        return vParked[vehicleid] = 0, SetPlayerWantedLevel(playerid, 1);
   
    if(GetPlayerWantedLevel(playerid) >= 1 && vParked[vehicleid] == 1) return 0;
    return 1;
}
pawn Код:
if(GetPlayerWantedLevel(playerid) >= 1 && vParked[vehicleid] == 1) return 0;
should be done before the check if the vehicle is parked. Otherwise it will still set your wanted level to 1 (even though it already is)
Reply
#9

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
pawn Код:
if(GetPlayerWantedLevel(playerid) >= 1 && vParked[vehicleid] == 1) return 0;
should be done before the check if the vehicle is parked. Otherwise it will still set your wanted level to 1 (even though it already is)
Yes, thanks for the correction :P

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetPlayerWantedLevel(playerid) >= 1 && vParked[vehicleid] == 1) return 0;

    if(vParked[vehicleid] == 1)
        return vParked[vehicleid] = 0, SetPlayerWantedLevel(playerid, 1);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)