/key command help. -
ReneG - 01.02.2012
I am trying to make it so that once a player enters a game all the vehicles engine's will be shut off and will not turn on until someone goes into the car and types "/key".
These are my variables. (Top of my script.)
pawn Код:
new iengine,ilights, ialarm, idoors,iboot, ibonnet, iobjective;
This is my OnPlayerUpdate part.
pawn Код:
public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new VID = GetPlayerVehicleID(playerid)
switch(VID)
{
case 1 .. 100:
{
GetVehicleParamsEx(VID,iengine,ilights, ialarm, idoors,iboot, ibonnet, iobjective);
SetVehicleParamsEx(VID,0,ilights,ialarm,idoors,iboot,ibonnet,iobjective);
return 1;
}
}
}
return 1;
}
and this is my /key command [zcmd]
pawn Код:
CMD:key(playerid,params[])
{
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,iengine,ilights,ialarm,idoors,iboot,ibonnet,iobjective);
if(IsPlayerInAnyVehicle(playerid))
{
if(iengine == 0)
{
SendClientMessage(playerid,COLOR_WHITE,"Vehicle started.");
SetVehicleParamsEx(vid,1,ilights,ialarm,idoors,ibonnet,iboot,iobjective);
return 1;
}
else if(iengine == 1)
{
SendClientMessage(playerid,COLOR_WHITE,"Vehicle started.");
SetVehicleParamsEx(vid,0,ilights,ialarm,idoors,ibonnet,iboot,iobjective);
return 1;
}
}
return 1;
}
I have no errors when I compile, but when I get in the car and type /key the engine only turns on for about half a second. Then shuts off. Can someone tell me what I'm doing wrong? I've ******d all over the place, and have spent a lot of time trying to figure it out but to no avail. Thank you.
Re: /key command help. -
-ExG-VirusKiller - 01.02.2012
Remove the onplayerupdate code and try.Because it is switching off the engine.
Re: /key command help. -
ReneG - 01.02.2012
Ahh, I see how that would be happening. So I just put the shutoff engine part under OnVehicleSpawn?
Re: /key command help. -
-ExG-VirusKiller - 01.02.2012
Yes.
Re: /key command help. -
Konstantinos - 01.02.2012
pawn Код:
new
iengine, ilights, ialarm, idoors, iboot, ibonnet, iobjective;
public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
new
VID = GetPlayerVehicleID( playerid );
switch(VID)
{
case 1 .. 100:
{
GetVehicleParamsEx( VID, iengine, ilights, ialarm, idoors, iboot, ibonnet, iobjective );
SetVehicleParamsEx( VID, 0, ilights, ialarm, idoors, iboot, ibonnet, iobjective );
return 1;
}
}
}
return 1;
}
CMD:key( playerid, params[ ] )
{
new
vid = GetPlayerVehicleID( playerid );
GetVehicleParamsEx( vid, iengine, ilights, ialarm, idoors, iboot, ibonnet, iobjective );
if( IsPlayerInAnyVehicle( playerid ) )
{
if( iengine == 0 ) // I am not sure about this if it's work.
{
SendClientMessage( playerid, COLOR_WHITE, "Vehicle started." );
SetVehicleParamsEx( vid, 1, ilights, ialarm, idoors, ibonnet, iboot, iobjective );
return 1;
}
else if( iengine == 1 )
{
SendClientMessage( playerid, COLOR_WHITE, "Vehicle started." );
SetVehicleParamsEx( vid, 0, ilights, ialarm, idoors, ibonnet, iboot, iobjective );
return 1;
}
}
return 1;
}