When Engine starts , +rep -
Jaber_Brown - 13.03.2012
I gots This
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
if(vehEngine[vehicleid] == 0)
{
if(newkeys == KEY_JUMP)
{
vehEngine[vehicleid] = 2;
SetTimerEx("StartEngine", 3000, 0, "i", playerid);
SendClientMessage(playerid, 0x33AA33AA, "Vehicle engine starting");
}
}
if(newkeys == KEY_SECONDARY_ATTACK)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
}
}
return 1;
}
After Engine starts i want an automatic /me ,%s(Player name) spins the %s(car name)'s key into the ignition and turns on the engine.
Re: When Engine starts , -
Jaber_Brown - 13.03.2012
anyone ?
Re: When Engine starts , -
antonio112 - 13.03.2012
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
if(vehEngine[vehicleid] == 0)
{
if(newkeys == KEY_JUMP)
{
new str[128], Name[MAX_PLAYER_NAME], pPos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerName(playerid, Name, sizeof Name);
format(str, sizeof str, "%s started the vehicle engine.", Name);
for (new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 20, Pos[0], Pos[1], Pos[2]))
SendClientMessage(i, 0xF9B7FFAA, str);
}
vehEngine[vehicleid] = 2;
SetTimerEx("StartEngine", 3000, 0, "i", playerid);
SendClientMessage(playerid, 0x33AA33AA, "Vehicle engine starting");
return 1;
}
}
if(newkeys == KEY_SECONDARY_ATTACK)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
}
}
return 1;
}
Re: When Engine starts , -
Jaber_Brown - 14.03.2012
I get these
C:\DOCUME~1\Jaber\Bureau\BASICR~1\FILTER~1\engine. pwn(63) : error 017: undefined symbol "Pos"
C:\DOCUME~1\Jaber\Bureau\BASICR~1\FILTER~1\engine. pwn(63) : warning 215: expression has no effect
C:\DOCUME~1\Jaber\Bureau\BASICR~1\FILTER~1\engine. pwn(63) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\Jaber\Bureau\BASICR~1\FILTER~1\engine. pwn(63) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Jaber\Bureau\BASICR~1\FILTER~1\engine. pwn(63) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: When Engine starts , -
PawnFox - 14.03.2012
the line 63 is ?
Re: When Engine starts , -
TTJJ - 14.03.2012
Hi Jaber_Brown,
If you already have a /me command defined you could try the following:
pawn Код:
OnPlayerCommandText(playerid,"/me starts the engine");
A quick and simple solution, just put it inside your command.
Cheers,
TJ
Re: When Engine starts , -
Jaber_Brown - 14.03.2012
Ok, Another thing, Even Players who seat in back seat can turn on/off the engine, how can i make only ppl who are in the driver seat can turn it on
Re: When Engine starts , -
TTJJ - 14.03.2012
Hi Again Jaber,
Adding the following if statement should prevent that:
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//Do Something...
}
Cheers,
TJ