Engine problem - 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: Engine problem (
/showthread.php?tid=486537)
Engine problem -
MatriXgaMer - 09.01.2014
pawn Код:
CMD:engine(playerid,params[])
{
if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)
{
new vID=GetPlayerVehicleID(playerid),
tmp_engine,
tmp_lights,
tmp_alarm,
tmp_doors,
tmp_bonnet,
tmp_boot,
tmp_objective;
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(tmp_engine==1){
tmp_engine = 0;
}else{
tmp_engine = 1;
}
SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
}
return 1;
}
I have this command and its not showing any errors but when i enter a car and write /engine nothing happnes.
Re: Engine problem -
amirab - 09.01.2014
Cause of this
PHP код:
if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)
{
change it to this:
PHP код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
Re: Engine problem -
[TMS]Legena - 09.01.2014
This works
Код:
new tmp_engine;
public OnVehicleSpawn(vehicleid)
{
tmp_engine = 1;
return 1;
}
CMD:engine(playerid,params[])
{
if(GetPlayerState(playerid)<= 1) return SendClientMessage(playerid,0xFFFFFF,"You need to be vehicle driver to use this command!");
{
new vID=GetPlayerVehicleID(playerid),
tmp_lights,
tmp_alarm,
tmp_doors,
tmp_bonnet,
tmp_boot,
tmp_objective;
if(tmp_engine == 0)
{
SendClientMessage(playerid,0xFFFFFF,"Engine is on!");
tmp_engine = 1;
SetVehicleParamsEx(vID, 1, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, 0);
}
else
{
SendClientMessage(playerid,0xFFFFFF,"Engine is off!");
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
SetVehicleParamsEx(vID, 0, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, 0);
tmp_engine = 0;
}
}
return 1;
}
Re: Engine problem -
iBots - 09.01.2014
You have to make it instead of:
pawn Код:
if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)
{
pawn Код:
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
because you want him to be the driver..,!= means :
if the player in any situation but not driver,it will work,so if you try with the old code and you are not the driver,i mean passenger,you can /engine,edit it and it work