0.3c Vehicle System
#1

I made this vehicle system and compiled it and got no errors but the only thing that works in game is the hood have i done something wrong??

pawn Код:
#include <a_samp>

#define VEHICLE_PARAMS_UNSET    -1 //This sets if your using the params
#define VEHICLE_PARAMS_OFF  0 //This will set your params OFF
#define VEHICLE_PARAMS_ON   1 //This will set your params ON

new engine,lights,alarm,doors,bonnet,boot,objective;

public OnGameModeInit()
{
     ManualVehicleEngineAndLights();
     return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/engine", true) == 0)
    {
        if(IsPlayerConnected(playerid))
     {
           new vid = GetPlayerVehicleID(playerid);
           if (engine == 1) // check if engine ON
           {
              if(vid != INVALID_VEHICLE_ID)
              {
                  GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                  SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                  engine = 0;
                  SendClientMessage(playerid, 0xFFFFFFAA, "You've turned the vehicle's engine {E31919}off!");
              }
           }
           else if (engine == 0) // check if engine off
           {
              if(vid != INVALID_VEHICLE_ID)
              {
                 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                 SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                 engine = 1;
                 SendClientMessage(playerid, 0xFFFFFFAA, "You've turned the vehicle's engine {2F991A}on!");
              }  
           }
        }
        return 1;
    }
    if(strcmp(cmdtext, "/lights", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
           new vid = GetPlayerVehicleID(playerid);
           if (lights == 1)
           {
              if(vid != INVALID_VEHICLE_ID)
              {
                  GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                  SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
                  lights = 0;
                  SendClientMessage(playerid, 0xFFFFFFAA, "You've turned the vehicle's lights {E31919}off!");
              }
           }
           else if (lights == 0)
           {
              if(vid != INVALID_VEHICLE_ID) {
             
                 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                 SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
                 lights = 1;
                 SendClientMessage(playerid, 0xFFFFFFAA, "You've turned the vehicle's lights {2F991A}on!");
              }
           }
        }
        return 1;
    }
    if(strcmp(cmdtext, "/hood", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
           new vid = GetPlayerVehicleID(playerid);
           if (bonnet == 1)
           {
              if(vid != INVALID_VEHICLE_ID)
              {
                  GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                  SetVehicleParamsEx(vid,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
                  bonnet = 0;
                  SendClientMessage(playerid, 0xFFFFFFAA, "The vehicle's hood is now {E31919}closed!");
              }
           }
           else if (bonnet == 0)
           {
              if(vid != INVALID_VEHICLE_ID) {

                 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                 SetVehicleParamsEx(vid,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
                 bonnet= 1;
                 SendClientMessage(playerid, 0xFFFFFFAA, "The vehicle's hood is now {2F991A}open!");
              }
           }
        }
        return 1;
    }
    if(strcmp(cmdtext, "/trunk", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
           new vid = GetPlayerVehicleID(playerid);
           if (boot == 1)
           {
              if(vid != INVALID_VEHICLE_ID)
              {
                  GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                  SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
                  boot = 0;
                  SendClientMessage(playerid, 0xFFFFFFAA, "The vehicle's trunk is now {E31919}closed!");
              }
           }
           else if (boot == 0)
           {
              if(vid != INVALID_VEHICLE_ID) {

                 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                 SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
                 boot = 1;
                 SendClientMessage(playerid, 0xFFFFFFAA, "The vehicle's trunk is now {2F991A}open!");
              }
           }
        }
        return 1;
    }
    return 0;
    }
Reply
#2

Have you tried this on several different vehicles in game ?
Reply
#3

Shouldn't you save to bonnet variable to the vehicle's ID?#

E.G.

pawn Код:
bonnet[vid] = 1;
Reply
#4

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Have you tried this on several different vehicles in game ?
yes i have and the only thing that seem to work is /hood
Reply
#5

Quote:
Originally Posted by Hashski
Посмотреть сообщение
Shouldn't you save to bonnet variable to the vehicle's ID?#

E.G.

pawn Код:
bonnet[vid] = 1;
I based it off the tutorial for but it seems that it only wants to do one command, if you do /engine then thats the only one you can do same with the rest
Reply
#6

What does it says InGame?"Unknown Command" or what?
Reply
#7

when i type /engine it tells me engine is on/off which works but when i go to type another command the server knows its there but doesnt active it for some unknown reason
Reply
#8

sorry double post
Reply
#9

OnGameModeInIt, Set your Vehicle Params to normal.

etc boot = 0;
Reply
#10

pawn Код:
else if(strcmp(x_nr,"trunk",true) == 0)
            {
                new cid = GetPlayerVehicleID(playerid);
                if(cid>0)
                {
                    GetVehicleParamsEx(cid,engine,lights,alarm,doors,bonnet,boot,objective);
                    if (boot == -1||boot==0)
                    {
                        SetVehicleParamsEx(cid,engine,lights,alarm,doors,bonnet,1,objective);
                        return 1;
                    }
                    if (engine ==1)
                    {
                        SetVehicleParamsEx(cid,engine,lights,alarm,doors,bonnet,0,objective);
                        return 1;
                    }
                }
                return 1;
            }
Is this what you need
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)