Exit from CAR - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Exit from CAR (
/showthread.php?tid=347917)
Exit from CAR -
MarcoWesley - 03.06.2012
Hi everybody, i'm again here for a question...
I have a problem, because when i'm in a car and i press enter key (Secondary attack), the engine must to be on to exit...so if the engine is off, i can't exit from the car.
This is my script for vehicle:
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
if (CarShopping[playerid] == false)
{
if(newkeys == KEY_SPRINT)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(vEngine[vehicleid] == 0 && !IsRentVehicle(vehicleid))
{
if(vehicleid>=210 && vehicleid<=235 && RentedVehicle[playerid] != vehicleid) return 1;
if(vTicket[vehicleid] > 0) return 1;
if(OutOfFuel[playerid]) return SendClientMessage(playerid, YELLOW, "Enough fuel.");
if(TryEngine[playerid]) return 1;
SetTimerEx("EngineOn", 3000, 0, "d", playerid);
PlayerActionMessage(playerid, 15.0, "Try to get engine On");
TryEngine[playerid] = 1;
GameTextForPlayer(playerid, "~r~Try to get engine on", 3000, 5);
return 1;
}
}
}
if(newkeys == KEY_SUBMISSION)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(vEngine[vehicleid] == 1 && !IsRentVehicle(vehicleid))
{
vEngine[vehicleid] = 0;
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, "~r~Engine OFF", 3000, 5);
BrowsingCar = 1;
SendClientMessage(playerid, YELLOW, "Engine Off. Press SPACE KEY to get it ON.");
return 1;
}
}
}
if(newkeys == KEY_SECONDARY_ATTACK)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(BrowsingCar == 1)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
BrowsingCar = 0;
return 1;
}
}
}
}
Can you help me? Thanks!!
Re: Exit from CAR -
milanosie - 03.06.2012
and what exactly is the problem?
Re: Exit from CAR -
MarcoWesley - 03.06.2012
The problem is that i want that when i press the enter key (so the button for exit from the vehicle), the character have to exit from the vehicle. But it exit only if the engine is ON. So i want that regardless of engine state, the character exit from the car...
Re: Exit from CAR -
TzAkS. - 03.06.2012
The player is not removed from vehicle?
Try something like this
Код:
if(newkeys == KEY_SECONDARY_ATTACK)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(BrowsingCar == 1)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
SetTimerEx("TurnOffEngine",3000,1,"i",playerid);
return 1;
}
}
}
Код:
forwarn TurnOffEngine(playerid);
public TurnOffEngine(playerid)
{
BrowsingCar = 0;
return 1;
}
Re: Exit from CAR -
MarcoWesley - 03.06.2012
I tried writing so:
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(BrowsingCar == 1)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
SetTimerEx("TurnOffEngine",3000,1,"i",playerid);
return 1;
}
}
}
forward TurnOffEngine(playerid);
public TurnOffEngine(playerid)
{
BrowsingCar = 0;
return 1;
}
}
It give me this errors:
Код:
C:\Users\Marco\Desktop\SwordCross City\gamemodes\crp.pwn(30725) : error 029: invalid expression, assumed zero
C:\Users\Marco\Desktop\SwordCross City\gamemodes\crp.pwn(30725) : error 017: undefined symbol "TurnOffEngine"
C:\Users\Marco\Desktop\SwordCross City\gamemodes\crp.pwn(30726) : error 029: invalid expression, assumed zero
C:\Users\Marco\Desktop\SwordCross City\gamemodes\crp.pwn(30726) : error 017: undefined symbol "TurnOffEngine"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Exit from CAR -
TzAkS. - 04.06.2012
This it need to be out of a callback.
Код:
forward TurnOffEngine(playerid);
public TurnOffEngine(playerid)
{
BrowsingCar = 0;
return 1;
}
}
Re: Exit from CAR -
MarcoWesley - 04.06.2012
What Callback do you mean?