Little bit of help about /engine
#1

Hello, My question is how to disable /engine for bicycles?!

I've added this under OnPlayerEnterVehicle

Код:
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
		{
		new engine, lights, alarm, doors, bonnet, boot, objective;
		GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
		SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
Alright, good for now, so it automatically starts the engine when I get on a bicycle, no need to type /engine.

So , that's my /engine command:
Код:
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);
	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
	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;
}
Added this line:
Код:
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
To prevent players turning off the "engine" of the bicycles, but it does nothing, any solutions ?
Reply
#2

Код:
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
vehicleid = GetPlayerVehicleID(playerid);
Should be:

Код:
vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
you cant check for certain vehicle id's if you havent actually set the vehicleid variable yet
Reply
#3

Yeah I tried that way too, doesnt work (tried it now again), maybe something else is wrong ? ;/
Reply
#4

Cant really spot whats wrong, i've added some brackets too the if statement, but doubt that was the problem.
So i just restructured it a bit, now it has an if-else statement for the vehicle id checks, maybe that helps?
Код:
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.");
    
    vehicleid = GetPlayerVehicleID(playerid);
    if((vehicleid == 509) || (vehicleid == 481) || (vehicleid == 510)) {
        SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
    } else {
        GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
        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;
}
Reply
#5

Well.. it didnt worked again, as you said, I dont see whats wrong with it..
Reply
#6

Strange stuff, you did compile the script and restart the server and such right?

How about maybe having some old version of the same command still lingering somewhere else in your code? or maybe an /engine command defined by a completelly different gamemode/filterscript?
You could try run a server with only the script your currently working on and see if that changes anything?
Reply
#7

I've compiled and restarted the server, also there isnt any other /engine command, neither in the filterscript, because I dont use such, everything is in the GM.

Well, I will leave it like that for now, till we find the solution or someone else lend a hand to solve the "mystery".
Reply
#8

PHP код:
vehicleid GetPlayerVehicleID(playerid);
    if((
vehicleid == 509) || (vehicleid == 481) || (vehicleid == 510)) { 
The vehicleid is not the same as the vehicle model, which you are looking for.

PHP код:
GetVehicleModel(vehicleid); 
^ This is what you need to do and check for.
Reply
#9

Well I fixed it already, the fix was simple:

Not working:
Код:
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
;
Working:
Код:
if (GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 510 || GetVehicleModel(vehicleid) == 509) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
Edit: Oh Sithis, didnt saw you posted, yeah that was the solution, anyway you will be +Repped, thanks!
Reply
#10

Quote:
Originally Posted by Dizzle
Посмотреть сообщение
Well I fixed it already, the fix was simple:

Not working:
Код:
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
;
Working:
Код:
if (GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 510 || GetVehicleModel(vehicleid) == 509) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
Edit: Oh Sithis, didnt saw you posted, yeah that was the solution, anyway you will be +Repped, thanks!
Glad to be of help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)