SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/05/2017, 06:26 PM   #1
freddiebox
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)
{
    if(
PlayerInfo[playerid][pCarDrivingTest] < || PlayerInfo[playerid][pTruckDrivingTest] < 1)
    {
         
GetPlayerVehicleID(playerid);
        
DestroyVehicle(vehicleid);
        
PlayerInfo[playerid][pDrivingTest] = 0;
DisablePlayerCheckpoint(playerid);
           
SetPlayerPos(playerid, -147.2725,1079.0540,19.7500);
         
SetPlayerFacingAngle(playerid88.3368);
          
SetPlayerInterior(playerid0);
          
SetCameraBehindPlayer(playerid);
        
SendClientMessage(playeridCOLOR_WHITE"{F0F8FF}You{F0F8FF} {FF6347}FAILED{FF6347} {F0F8FF}the driving test for abandoning the license vehicle.{F0F8FF}");
        return 
1;
    }
    return 
1;

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, 06:42 PM   #2
Aly
Huge Clucker
 
Join Date: Oct 2012
Posts: 227
Reputation: 11
Default Re: Driving Test & OnPlayerExitVehicle

You can use a global boolean variable
Code:
new bool:isTakingDrivingTest[MAX_PLAYERS];
Set it to false inside OnPlayerConnect
Code:
public OnPlayerConnect(playerid)
{
     isTakingDrivingTest[playerid] = false;
}
You can set it to true when the player starts the driving test
Code:
isTakingDrivingTest[playerid] = true;
Set it to false when the player ends the driving test or when he leaves the vehicle.
Code:
if(PlayerEndedTest)
	isTakingDrivingTest[playerid] = false;
And OnPlayerExitVehicle
Code:
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
        DestroyVehicle(vehicleid); 
        PlayerInfo[playerid][pDrivingTest] = 0; 
		DisablePlayerCheckpoint(playerid); 
        SetPlayerPos(playerid, -147.2725,1079.0540,19.7500); 
        SetPlayerFacingAngle(playerid, 88.3368); 
        SetPlayerInterior(playerid, 0); 
        SetCameraBehindPlayer(playerid); 
        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
Reply

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 04:51 PM
[FilterScript] Driving Test mbk Filterscripts 2 27/08/2010 06:30 AM
[Help] Driving test DeltaResponseRP Help Archive 2 13/06/2010 04:32 PM
Driving Test owner jacob Help Archive 0 15/02/2010 01:44 PM
[Help] Driving test Unwritten Help Archive 0 22/11/2009 01:42 AM


All times are GMT. The time now is 11:14 AM.


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