Engine problem
#1

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.
Reply
#2

Cause of this

PHP код:
if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)

change it to this:

PHP код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)

Reply
#3

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;
}
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)