SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Thread Tools Display Modes
Old 19/05/2017, 07:26 PM   #1
Little Clucker
Join Date: Dec 2014
Location: Sweden
Posts: 15
Reputation: 0
Default Driving Test & OnPlayerExitVehicle

Hello everyone,

I got a simple system I'm working on recognizing if a player is taking a driving license test and if the player leave the vehicle during the exam it should return the player to the DMV and cancel the test.

So far the returning the player to the DMV is working properly, but I'm trying to understand how to get it to know if the player is taking the test or not. Right now it kicks the player from any vehicle even if they are not doing a test.

PlayerInfo[playerid][pCarDrivingTest] gets updated when the player enters a checkpoint during the test. If the player is not taking a driving test it is per default at 0, but if a player is taking the test the value can be anywhere between 1-51 depending on how many checkpoints the driving exam got.

PHP Code:
public OnPlayerExitVehicle(playeridvehicleid)
PlayerInfo[playerid][pCarDrivingTest] < || PlayerInfo[playerid][pTruckDrivingTest] < 1)
PlayerInfo[playerid][pDrivingTest] = 0;
SetPlayerPos(playerid, -147.2725,1079.0540,19.7500);
SendClientMessage(playeridCOLOR_WHITE"{F0F8FF}You{F0F8FF} {FF6347}FAILED{FF6347} {F0F8FF}the driving test for abandoning the license vehicle.{F0F8FF}");

So how do I get it to know if the value is anywhere above 0?
freddiebox is offline   Reply With Quote
Old 19/05/2017, 07:42 PM   #2
Huge Clucker
Join Date: Oct 2012
Posts: 227
Reputation: 11
Default Re: Driving Test & OnPlayerExitVehicle

You can use a global boolean variable
new bool:isTakingDrivingTest[MAX_PLAYERS];
Set it to false inside OnPlayerConnect
public OnPlayerConnect(playerid)
     isTakingDrivingTest[playerid] = false;
You can set it to true when the player starts the driving test
isTakingDrivingTest[playerid] = true;
Set it to false when the player ends the driving test or when he leaves the vehicle.
	isTakingDrivingTest[playerid] = false;
And OnPlayerExitVehicle
public OnPlayerExitVehicle(playerid, vehicleid) 
    if(!isTakingDrivingTest[playerid]) //is the same as using: if(isTakingDrivingTest[playerid] == false)
        GetPlayerVehicleID(playerid); //This line should be deleted because you're not storing its result in any variable so is useless
        PlayerInfo[playerid][pDrivingTest] = 0; 
        SetPlayerPos(playerid, -147.2725,1079.0540,19.7500); 
        SetPlayerFacingAngle(playerid, 88.3368); 
        SetPlayerInterior(playerid, 0); 
        SendClientMessage(playerid, COLOR_WHITE, "{F0F8FF}You{F0F8FF} {FF6347}FAILED{FF6347} {F0F8FF}the driving test for abandoning the license vehicle.{F0F8FF}"); 
        return 1; 
    return 1; 
Aly is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
I have bug on my driving test help me Kenway Scripting Help 6 30/01/2013 05:51 PM
[FilterScript] Driving Test mbk Filterscripts 2 27/08/2010 07:30 AM
[Help] Driving test DeltaResponseRP Help Archive 2 13/06/2010 05:32 PM
Driving Test owner jacob Help Archive 0 15/02/2010 02:44 PM
[Help] Driving test Unwritten Help Archive 0 22/11/2009 02:42 AM

All times are GMT. The time now is 07:01 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.