Bug (Urgent help) [pre-release] -
Squirrel - 24.03.2013
It's showing message whenever you enter ANY vehicle, and it should only display the dialog when you enter [0] - [7] car...
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new CarCheck = GetPlayerVehicleID(playerid);
if(CarCheck == DSchool[0] || DSchool[1] || CarCheck == DSchool[2] || CarCheck == DSchool[3] || CarCheck == DSchool[4] || CarCheck == DSchool[5]
|| CarCheck == DSchool[6] || CarCheck == DSchool[7])
{
if(PlayerInfo[playerid][pDriversLic] == 0)
{
ShowPlayerDialog(playerid, DRIVERS_TEST, DIALOG_STYLE_MSGBOX, "Notice", "Would you like to take drivers test?\nIt will cost you 50$", "Yes", "No");
return 1;
}
else
{
return 1;
}
}
else
{
return 1;
}
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
new CarCheck = GetPlayerVehicleID(playerid);
if(CarCheck == DSchool[0] || DSchool[1] || CarCheck == DSchool[2] || CarCheck == DSchool[3] || CarCheck == DSchool[4] || CarCheck == DSchool[5] || CarCheck == DSchool[6] || CarCheck == DSchool[7])
{
if(DriversTest[playerid] == 1)
{
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, COLOR_RED, "<!>You have left your vehicle and failed drivers test!");
DriversTest[playerid] = 0;
return 1;
}
}
return 1;
}
It should work like if you enter vehicle from Dschool[0] to Dschool[7] it will display the dialog. But currently it's showing the dialog if you enter ANY vehicle.
Re: Bug (Urgent help) [pre-release] -
Joshman543 - 24.03.2013
Show me where you have Dschool defined.
Re: Bug (Urgent help) [pre-release] -
Squirrel - 24.03.2013
Here you go
Код:
//top
new DSchool[8];
//OnGameModeInit
DSchool[0] = AddStaticVehicleEx(405,-2089.5093000,-83.0658000,34.8702000,0.9792000,1,1,1800);
DSchool[1] = AddStaticVehicleEx(405,-2093.5562000,-84.3461000,34.8708000,359.4012000,1,1,1800);
DSchool[2] = AddStaticVehicleEx(405,-2085.3455000,-83.4514000,34.8706000,359.6392000,1,1,1800);
DSchool[3] = AddStaticVehicleEx(405,-2081.0051000,-83.4199000,34.8679000,359.5697000,1,1,1800);
DSchool[4] = AddStaticVehicleEx(405,-2076.8577000,-82.8295000,34.8714000,0.8467000,1,1,1800);
DSchool[5] = AddStaticVehicleEx(405,-2072.6670000,-82.9938000,34.8700000,0.0420000,1,1,1800);
DSchool[6] = AddStaticVehicleEx(405,-2068.7861000,-83.1322000,34.8707000,359.0753000,1,1,1800);
DSchool[7] = AddStaticVehicleEx(405,-2064.2036000,-83.1249000,34.8721000,359.5125000,1,1,1800);
DSchool are just the cars used for the drivers school.
Re: Bug (Urgent help) [pre-release] -
FunnyBear - 24.03.2013
I had a similar problem a few days ago. Look,
https://sampforum.blast.hk/showthread.php?tid=424299
You need to group your conditions
Re: Bug (Urgent help) [pre-release] -
Squirrel - 24.03.2013
Tried with that too..
This format
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new CarCheck = GetPlayerVehicleID(playerid);
if(CarCheck == DSchool[0] || DSchool[1] || CarCheck == DSchool[2] || CarCheck == DSchool[3] || CarCheck == DSchool[4] || CarCheck == DSchool[5]
|| CarCheck == DSchool[6] || CarCheck == DSchool[7])
{
if(PlayerInfo[playerid][pDriversLic] == 0)
{
ShowPlayerDialog(playerid, DRIVERS_TEST, DIALOG_STYLE_MSGBOX, "Notice", "Would you like to take drivers test?\nIt will cost you 50$", "Yes", "No");
return 1;
}
}
}
return 1;
}
But it shows the same issue
Re: Bug (Urgent help) [pre-release] -
Joshman543 - 24.03.2013
Instead of this
pawn Код:
if(CarCheck == DSchool[0] || DSchool[1] || CarCheck == DSchool[2] || CarCheck == DSchool[3] || CarCheck == DSchool[4] || CarCheck == DSchool[5]
|| CarCheck == DSchool[6] || CarCheck == DSchool[7])
Try this
pawn Код:
stock IsDschoolV(vehicleid)
{
for(new i=0; i<15; idx++)
{
if(vehicleid == DSchool[idx]) return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(IsDschoolV(vehicleid)
{
if(PlayerInfo[playerid][pDriversLic] == 0)
{
ShowPlayerDialog(playerid, DRIVERS_TEST, DIALOG_STYLE_MSGBOX, "Notice", "Would you like to take drivers test?\nIt will cost you 50$", "Yes", "No");
return 1;
}
else
{
return 1;
}
}
else
{
return 1;
}
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsDschoolV(vehicleid)
{
if(DriversTest[playerid] == 1)
{
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, COLOR_RED, "<!>You have left your vehicle and failed drivers test!");
DriversTest[playerid] = 0;
return 1;
}
}
return 1;
}
}
Re: Bug (Urgent help) [pre-release] -
FunnyBear - 24.03.2013
Maybe try changing [0]'[1] etc.. To just a new variable like. Car1, car2, etc..
Re: Bug (Urgent help) [pre-release] -
Squirrel - 24.03.2013
@Joshman nope, wont work
@FunnyBear I dont think it would work but i'll try it
Re: Bug (Urgent help) [pre-release] -
Joshman543 - 24.03.2013
Do you have this in your code?
new Dschool[8];
Re: Bug (Urgent help) [pre-release] - Patrick - 24.03.2013
so i looped your
DSchool vehicles its much easier and save you a space
Try This Code
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new CarCheck = GetPlayerVehicleID(playerid);
for(new i = 0; i < sizeof(DSchool); i++)//loop for all DSchool
{
if(CarCheck == DSchool[i])
{
if(PlayerInfo[playerid][pDriversLic] == 0)
{
ShowPlayerDialog(playerid, DRIVERS_TEST, DIALOG_STYLE_MSGBOX, "Notice", "Would you like to take drivers test?\nIt will cost you 50$", "Yes", "No");
return 1;
}
}
}
}
return 1;
}