PDA

View Full Version : Creating System


EvoGT
21/09/2013, 10:20 AM
Hello.
Today i decided to create a Car License System.
What i want to do?
When player enters any car without license, will be ejected.
When player enters a Drive test car, he's have to do test.
And Save system, i will try to make it, i hope some help

Lets try..

#include <a_samp>
#include <YSI/y_ini>

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;

public OnFilterScriptInit()

//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese.. WARN ME IF I USE WRONG FUNCTION..

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new string[128];
//" CHECK IF PLAYER HAS LICENSE"
RemovePlayerFromVehicle(playerid);
return 1;
}


What's next. what i did wrong?
Waiting for your help .

Konstantinos
21/09/2013, 10:27 AM
OnPlayerEnterVehicle:
This callback is called when a player starts to enter a vehicle, meaning the player is not in vehicle yet at the time this callback is called.


The player is not in the vehicle so RemovePlayerFromVehicle won't work. Use OnPlayerStateChange instead.

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
//if player does not have license -> RemovePlayerFromVehicle(playerid);
}
return 1;
}

EvoGT
21/09/2013, 10:53 AM
OnPlayerEnterVehicle:

The player is not in the vehicle so RemovePlayerFromVehicle won't work. Use OnPlayerStateChange instead.

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
//if player does not have license -> RemovePlayerFromVehicle(playerid);
}
return 1;
}


Now i need input this somewhere:

if(car == examCar1 || car == examCar2 || car == examCar3 || car == examCar4 || car == examCar5)

Konstantinos
21/09/2013, 10:55 AM
What those vehicles are for? Drive test or just vehicles to see if it works?

EvoGT
21/09/2013, 11:01 AM
What those vehicles are for? Drive test or just vehicles to see if it works?

Drive Test Vehicles, to do the exam.

Konstantinos
21/09/2013, 11:05 AM
public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5:
{
// Force him to do the test
}
}
//if player does not have license -> RemovePlayerFromVehicle(playerid);
}
return 1;
}

EvoGT
21/09/2013, 11:28 AM
Now the code looks like:

#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>

#define COLOR_GREEN 0x00FF00FF

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;
new CP[MAX_PLAYERS];

public OnFilterScriptInit()

//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5:
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
//if player does not have license -> RemovePlayerFromVehicle(playerid);
}
return 1;
}

//When player writes /exam in examcars..

CMD:exam(playerid, params[])
{
if(IsPlayerInVehicle(playerid,examCar1) || IsPlayerInVehicle(playerid,examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
{
TogglePlayerControllable(playerid, 1);
CP[playerid] = 200;
SetPlayerCheckpoint(playerid, 2073.780029,-1912.620361,13.244957, 4.0);
SendClientMessage(playerid, COLOR_GREEN, "Be Careful");
}
else return SendClientMessage(playerid, COLOR_GREEN,"You not in exam car");
return 1;
}

Next step i think, to add cp's

DanishHaq
21/09/2013, 11:31 AM
Use this callback: http://wiki.sa-mp.com/wiki/OnPlayerEnterCheckpoint. Once they enter a checkpoint, then you can set their next checkpoint with a different CP ID, and once they get to the last checkpoint, you can give them a drivers license. Understanding how to use OnPlayerEnterCheckpoint would easily increase your knowledge and understanding how to make jobs as well, i.e. trucker jobs to drive to a place.

EvoGT
21/09/2013, 12:19 PM
Tryed to add some cp's am i wrong ?

#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>

#define COLOR_GREEN 0x00FF00FF

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;
new Ccp[MAX_PLAYERS];

public OnFilterScriptInit()

//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5:
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
//if player does not have license -> RemovePlayerFromVehicle(playerid);
}
return 1;
}

//When player writes /exam in examcars..

CMD:exam(playerid, params[])
{
if(IsPlayerInVehicle(playerid, examCar1) || IsPlayerInVehicle(playerid, examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
{
Ccp[playerid] = 1;
SetPlayerCheckpoint(playerid, 2073.780029,-1912.620361,13.244957, 5.0);
SendClientMessage(playerid, COLOR_GREEN, "Be careful");
}
else return SendClientMessage(playerid, COLOR_GREEN, "You not in exam car");
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if(Ccp[playerid] == 1)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 2;
SetPlayerCheckpoint(playerid, 2079.123291,-1871.586303,13.048537, 5.0);
return 1;
}
if(Ccp[playerid] == 2)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 3;
SetPlayerCheckpoint(playerid, 2079.742431,-1802.388427,13.081876, 5.0);
}
if(Ccp[playerid] == 3)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 4;
SetPlayerCheckpoint(playerid, 2087.171142,-1763.789306,13.093797, 5.0);
}
return 1;
}

DanishHaq
21/09/2013, 12:21 PM
Use else if, and there's no need to return a value under the if's.

public OnPlayerEnterCheckpoint(playerid)
{
if(Ccp[playerid] == 1)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 2;
SetPlayerCheckpoint(playerid, 2079.123291,-1871.586303,13.048537, 5.0);
}
else if(Ccp[playerid] == 2)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 3;
SetPlayerCheckpoint(playerid, 2079.742431,-1802.388427,13.081876, 5.0);
}
else if(Ccp[playerid] == 3)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 4;
SetPlayerCheckpoint(playerid, 2087.171142,-1763.789306,13.093797, 5.0);
}
return 1;
}

EvoGT
21/09/2013, 12:50 PM
And now it is the hardest part
i included <YSI/y_ini> for save license.

At the last CP, i need to check if the player is in exam car, and check the damage.

If player is not in exam car, or car damage is low, test failed.
If player is in exam car and car damage is ok, test passed, and player obtain license.
I will use INI.
I will try, but i need help..


#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>

#define COLOR_GREEN 0x00FF00FF

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;
new Ccp[MAX_PLAYERS];

public OnFilterScriptInit()

//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5:
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
// Check if player has license... ~> RemovePlayerFromVehicle(playerid);
}
return 1;
}

//When player writes /exam in examcars..

CMD:exam(playerid, params[])
{
if(IsPlayerInVehicle(playerid, examCar1) || IsPlayerInVehicle(playerid, examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
{
Ccp[playerid] = 1;
SetPlayerCheckpoint(playerid, 2073.780029,-1912.620361,13.244957, 5.0);
SendClientMessage(playerid, COLOR_GREEN, "Be careful");
}
else return SendClientMessage(playerid, COLOR_GREEN, "You not in exam car");
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if(Ccp[playerid] == 1)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 2;
SetPlayerCheckpoint(playerid, 2079.123291,-1871.586303,13.048537, 5.0);
}
else if(Ccp[playerid] == 2)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 3;
SetPlayerCheckpoint(playerid, 2079.742431,-1802.388427,13.081876, 5.0);
}
else if(Ccp[playerid] == 3)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 4;
SetPlayerCheckpoint(playerid, 2087.171142,-1763.789306,13.093797, 5.0);
}
else if(Ccp[playerid] == 3)
{
if(IsPlayerInVehicle(playerid, examCar1) || IsPlayerInVehicle(playerid, examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
// Check Car Damage HOW TO ?
DisablePlayerCheckpoint(playerid);
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
GivePlayerMoney(playerid,-500);
SendClientMessage(playerid, COLOR_GREEN,"You passed the test");
}
else
{

DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, COLOR_GREEN,"You failed the test");
}
return 1;
}


// IF TEST PASSED SAVE it to FILE...

DanishHaq
21/09/2013, 12:58 PM
Follow this tutorial to make the player account file: http://forum.sa-mp.com/showthread.php?t=273088.

After that, when the player is done, use your variable to set the player's drivers license, use http://wiki.sa-mp.com/wiki/GetVehicleHealth and use http://wiki.sa-mp.com/wiki/Function:IsPlayerInVehicle to check if he's in an exam vehicle, after that, if all those are correct you can use:

PlayerInfo[playerid][pLicense] = 1;

Or whatever your license variable is. Then under OnPlayerStateChange, if the new state is a driver and he doesn't have a drivers license, remove him from the vehicle.

benjaminjones
21/09/2013, 12:59 PM
Use else if, and there's no need to return a value under the if's.

public OnPlayerEnterCheckpoint(playerid)
{
if(Ccp[playerid] == 1)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 2;
SetPlayerCheckpoint(playerid, 2079.123291,-1871.586303,13.048537, 5.0);
}
else if(Ccp[playerid] == 2)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 3;
SetPlayerCheckpoint(playerid, 2079.742431,-1802.388427,13.081876, 5.0);
}
else if(Ccp[playerid] == 3)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 4;
SetPlayerCheckpoint(playerid, 2087.171142,-1763.789306,13.093797, 5.0);
}
return 1;
}

I think so

EvoGT
21/09/2013, 01:13 PM
The last 2 Steps..
I dont know what to do.
In the script i marked it // I DONT KNOW HOW

#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>

#define COLOR_GREEN 0x00FF00FF
#define PATH "/Exam/%s.ini"

enum pInfo
{
pLic
}
new PlayerInfo[MAX_PLAYERS][pInfo];

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;
new Ccp[MAX_PLAYERS];

public OnFilterScriptInit()

//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5:
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
// Check player License. I DONT KNOW HOW ~> RemovePlayerFromVehicle(playerid);
}
return 1;
}

//When player writes /exam in examcars..

CMD:exam(playerid, params[])
{
if(IsPlayerInVehicle(playerid, examCar1) || IsPlayerInVehicle(playerid, examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
{
Ccp[playerid] = 1;
SetPlayerCheckpoint(playerid, 2073.780029,-1912.620361,13.244957, 5.0);
SendClientMessage(playerid, COLOR_GREEN, "Be careful");
}
else return SendClientMessage(playerid, COLOR_GREEN, "You not in exam car");
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if(Ccp[playerid] == 1)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 2;
SetPlayerCheckpoint(playerid, 2079.123291,-1871.586303,13.048537, 5.0);
}
else if(Ccp[playerid] == 2)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 3;
SetPlayerCheckpoint(playerid, 2079.742431,-1802.388427,13.081876, 5.0);
}
else if(Ccp[playerid] == 3)
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 4;
SetPlayerCheckpoint(playerid, 2087.171142,-1763.789306,13.093797, 5.0);
}
else if(Ccp[playerid] == 3)
{
if(IsPlayerInVehicle(playerid, examCar1) || IsPlayerInVehicle(playerid, examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
DisablePlayerCheckpoint(playerid);
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
GivePlayerMoney(playerid,-500);
SendClientMessage(playerid, COLOR_GREEN,"You passed the test");
// Set License +1... I DONT KNOW HOW
}
else
{

DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, COLOR_GREEN,"You failed the test");
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"pLic",PlayerInfo[playerid][pLic]);
INI_Close(File);
return 1;
}

stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

DanishHaq
21/09/2013, 01:18 PM
// Set License +1... I DONT KNOW HOW

PlayerInfo[playerid][pLic] = 1;

// Check player License. I DONT KNOW HOW ~> RemovePlayerFromVehicle(playerid);

if(PlayerInfo[playerid][pLic] == 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "You already have a license");
return 1;
}

EvoGT
21/09/2013, 02:38 PM
I Got 2 Errors when compiling.

C:\Users\FS2009\Desktop\exam - Copy.pwn(26) : error 010: invalid function or declaration
C:\Users\FS2009\Desktop\exam - Copy.pwn(43) : error 008: must be a constant expression; assumed zero
C:\Users\FS2009\Desktop\exam - Copy.pwn(50) : warning 217: loose indentation
C:\Users\FS2009\Desktop\exam - Copy.pwn(53) : warning 217: loose indentation
C:\Users\FS2009\Desktop\exam - Copy.pwn(70) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

public OnFilterScriptInit()

//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);//
examCar2 = AddStaticVehicle(405,2056.949951,-1903.704101,13.243331,1,1,15);// LINE 26
examCar3 = AddStaticVehicle(405,2057.206787,-1903.883056,13.243336,1,1,15);//
examCar4 = AddStaticVehicle(405,2068.361328,-1903.624877,13.243142,1,1,15);//
examCar5 = AddStaticVehicle(405,2069.629150,-1903.980712,13.243326,1,1,15);//


//When player enter car without lincese

...


new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5: // LINE 43
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}

Konstantinos
21/09/2013, 02:40 PM
public OnFilterScriptInit()
{
//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);//
examCar2 = AddStaticVehicle(405,2056.949951,-1903.704101,13.243331,1,1,15);// LINE 26
examCar3 = AddStaticVehicle(405,2057.206787,-1903.883056,13.243336,1,1,15);//
examCar4 = AddStaticVehicle(405,2068.361328,-1903.624877,13.243142,1,1,15);//
examCar5 = AddStaticVehicle(405,2069.629150,-1903.980712,13.243326,1,1,15);//
return 1;
}


new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5: // LINE 43
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}

EvoGT
21/09/2013, 02:46 PM
Still error on 43.

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5: // LINE 43
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
{
if(PlayerInfo[playerid][pLic] == 1)
RemovePlayerFromVehicle(playerid);
}
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "Eik nx");
return 1;
}

Aldo.
21/09/2013, 02:54 PM
OnPlayerEnterVehicle:

The player is not in the vehicle so RemovePlayerFromVehicle won't work. Use OnPlayerStateChange instead.

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
//if player does not have license -> RemovePlayerFromVehicle(playerid);
}
return 1;
}


You can use OnPlayerEnterVehicle, just get the player pos and set that to their pos to stop them from entering

Dragonsaurus
21/09/2013, 02:55 PM
Change to:new examcar[5];

examcar[0] = AddStaticVehicle(...);
examcar[1] = AddStaticVehicle(...);
// Other cars...

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
if(PlayerInfo[playerid][pLic] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "Eik nx");
return 1;
}
new veh = GetPlayerVehicleID( playerid );
switch( veh )
{
case examcar[0], examcar[1], examcar[2], examcar[3], examcar[4]: // LINE 43
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
}
return 1;
}

EvoGT
21/09/2013, 03:20 PM
Change to:new examcar[5];

examcar[0] = AddStaticVehicle(...);
examcar[1] = AddStaticVehicle(...);
// Other cars...

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
if(PlayerInfo[playerid][pLic] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "Eik nx");
return 1;
}
new veh = GetPlayerVehicleID( playerid );
switch( veh )
{
case examcar[0], examcar[1], examcar[2], examcar[3], examcar[4]: // LINE 43
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
}
return 1;
}

When i do this i got more more errors..

EvoGT
21/09/2013, 03:23 PM
Last 1 error :/

C:\Users\FS2009\Desktop\sss - Copy.pwn(44) : error 008: must be a constant expression; assumed zero

public OnFilterScriptInit()
{
//Exam Cars

examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);//
examCar2 = AddStaticVehicle(405,2056.949951,-1903.704101,13.243331,1,1,15);//
examCar3 = AddStaticVehicle(405,2057.206787,-1903.883056,13.243336,1,1,15);//
examCar4 = AddStaticVehicle(405,2068.361328,-1903.624877,13.243142,1,1,15);//
examCar5 = AddStaticVehicle(405,2069.629150,-1903.980712,13.243326,1,1,15);//
return 1;
}

//When player enter car without linces

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5: // ERROR HERE... Line 44
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
if(PlayerInfo[playerid][pLic] == 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "You already have a license");
return 1;
}
}
return 1;
}

//When player writes /exam in examcars..

DanishHaq
21/09/2013, 03:25 PM
Can you post the error too?

EvoGT
21/09/2013, 03:27 PM
Can you post the error too?

posted

EvoGT
21/09/2013, 04:07 PM
I cant understand what i did wrong..

Konstantinos
21/09/2013, 05:11 PM
Still error on 43.

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5: // LINE 43
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
}
}
{
if(PlayerInfo[playerid][pLic] == 1)
RemovePlayerFromVehicle(playerid);
}
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "Eik nx");
return 1;
}

Missing brackets.

public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
veh = GetPlayerVehicleID( playerid )
;
switch( veh )
{
case examCar1, examCar2, examCar3, examCar4, examCar5: // LINE 43
{
SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
return 1;
}
}
if(PlayerInfo[playerid][pLic] == 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREEN, "Eik nx");
return 1;
}
}
return 1;
}


You can use OnPlayerEnterVehicle, just get the player pos and set that to their pos to stop them from entering

The player is not in the vehicle so RemovePlayerFromVehicle won't work. Use OnPlayerStateChange instead.


I was talking about the function, plus it's more realistic to force the player to exit the vehicle normal that set their position.