Maunal engine and lights help? -
drewcasey24 - 07.10.2012
Ok i have the ManualVehicleEngineAndLights(); in my ongamemodeint but for some reason in the server when ever i do the /engine cmd to turn it on for the first time after the vehicle loads it says you turned the engine off and i have to /engine again to turn it on so im doing /engine twice any ideas of what could be causing this?
Re: Maunal engine and lights help? -
Riddick94 - 07.10.2012
Show commands.. i know where's the problem but i need to see your way of doing that.
Re: Maunal engine and lights help? -
drewcasey24 - 07.10.2012
Код:
CMD:engine(playerid, params[])
{
new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
vehicleid = GetPlayerVehicleID(playerid);
new id = GetVehicleID(vehicleid);
if(GetPlayerVehicleAccess(playerid, id) < 1) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(Fuel[vehicleid] <= 0)
{
GameTextForPlayer(playerid, "~r~out of fuel", 3000, 3);
SendClientMessage(playerid, COLOR_RED, "This vehicle is out of fuel!");
}
else if(!engine)
{
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
{SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
{SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
format(string, sizeof(string), "* %s turns the vehicle's engine on.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
else
{
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
{SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
{SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
format(string, sizeof(string), "* %s turns the vehicle's engine off.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
return 1;
}
Re: Maunal engine and lights help? -
Riddick94 - 07.10.2012
pawn Код:
CMD:engine(playerid, params[])
{
new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid = GetPlayerVehicleID(playerid), string[128];
if(!IsPlayerLoggedIn(playerid))return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
if(GetPlayerVehicleAccess(playerid, vehicleid) < 1) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(Fuel[vehicleid] <= 0)
{
GameTextForPlayer(playerid, "~r~out of fuel", 3000, 3);
SendClientMessage(playerid, COLOR_RED, "This vehicle is out of fuel!");
}
if(engine > 0)
{
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
{SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
{SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
format(string, sizeof(string), "* %s turns the vehicle's engine off.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
else
{
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
{SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
{SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
format(string, sizeof(string), "* %s turns the vehicle's engine on.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
return 1;
}
First of all, you have declared twice a GetPlayerVehicleID(playerid) function. In vehicleid and id variable. Secondly your if statement with vehicle equals won't work because your vehicleid variable has been set right after your if statement. Third thing is.. go and check your code. Is it working or not, i think it should.
Re: Maunal engine and lights help? -
drewcasey24 - 07.10.2012
ok i'll make those changes
EDIT: Thanks worked great lights are doing the same thing so i'll adjust that cmd as well, i didn't write these original codes and still not that great at coding so yea. Thanks again
Re: Maunal engine and lights help? -
Riddick94 - 07.10.2012
I've already done them. Do not change anything in the code that i gave you. Just replace it with your old one and check is it compiled fine.
edit://
Sorry. The 'new id = GetVehicleID(...);' was fine. I just red that like GetPlayerVehicleID(playerid). My mistake, sorry. Just add it again.