[help]little help here, please
#1

So I was making CMDs related with vehicles and if really I don't get it why this works:
pawn Код:
if(!strcmp(cmdtext,"/engine",true))
    {
        new carid = GetPlayerVehicleID(playerid);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
        new IsOwner[MAX_PLAYER_NAME];
        GetPlayerName(playerid, IsOwner, sizeof(IsOwner));
        new vehicleid = GetPlayerVehicleID(playerid);

        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(strmatch(CarInfo[vehicleid][owner], IsOwner))
            {
                if(CarInfo[carid][fuel] > 0)
                {
                    if(engine == 0)
                    {
                        SetVehicleParamsEx(carid,1,lights,alarm,doors,bonnet,boot,objective);
                    }
                    if(engine == 1)
                    {
                        SetVehicleParamsEx(carid,0,lights,alarm,doors,bonnet,boot,objective);
                    }
                }
            }
            else
            {
            }
        }

        return 1;
    }
and this not
pawn Код:
if(!strcmp(cmdtext,"/lock",true))
    {
        new carid = GetPlayerVehicleID(playerid);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);

        for(new i = 0; i < MAX_VEHICLES; i++)
        {
            new Float:px, Float:py, Float:pz;
            GetPlayerPos(playerid, px, py, pz);
            if(VehicleToPoint(5, i, px, py, pz))
            {
                new IsOwner[MAX_PLAYER_NAME];
                GetPlayerName(playerid, IsOwner, sizeof(IsOwner));

                if(strmatch(CarInfo[i][owner], IsOwner))
                {
                    if(doors == 0)
                    {
                        SetVehicleParamsEx(i,engine,lights,alarm,1,bonnet,boot,objective);
                    }
                    if(doors == 1)
                    {
                        SetVehicleParamsEx(i,engine,lights,alarm,0,bonnet,boot,objective);
                    }
                }
            }
        }
        return 1;
    }
Engine turns up and off with /engine cmd, but car just get's locked with /lock. Why is that? Why it doesn't lock and unlock car with the same CMD? Can anyone help me?

P.S. Sorry for possible grammar mistakes.
Reply
#2

I think you need to make a loop throug all players, and like - lock the car for them ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)