[Ajuda] /Motor
#1

Preciso de ajuda com esse Sistema , queria que quando entrasse no servidor e quando entrar em algum veнculo o veнculo permaneзa desligado e para ligar o player teria que digitar o comando /motor e tbm tem um bug й que o passageiro consegue desligar o veнculo .

pawn Код:
//Topo
new motor[MAX_PLAYERS];
new LigadoDesligado2[MAX_VEHICLES] = 0;

stock LigadoDesligado(carid)//desativado
{
    new txt[20];
    if(LigadoDesligado2[carid] == 0)
    {
        format(txt, sizeof(txt),"~r~Desligado");
    }
    else if(LigadoDesligado2[carid] == 1)
    {
        format(txt, sizeof(txt),"Ligado");
    }
    return txt;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    motor[playerid] = 0;
    new string[256];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* %s Entrou no Veнculo.", sendername);
    ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    if(Trancado[vehicleid] >= 1)
    {
        if(PlayerInfo[playerid][pAdmin] > 0 || ispassenger) { }
        else
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            SetPlayerPos(playerid, x, y, z+0.3);
            SetPlayerFacingAngle(playerid, a);
            SendClientMessage(playerid, COLOR_YELLOW, "Veiculo Trancado!");
        }
    }
    return true;
}
//Comando
if(strcmp("/motor",cmdtext,true,6)==0)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid,COLOR_GREY,"Vocк precisa estar em um veнculo!");
            return 1;
        }
        new mot, lu, alar, por, cap, porma, ob;
        new carro = GetPlayerVehicleID(playerid);

        new vid = GetPlayerVehicleID(playerid);
        if(Gas[vid] == 0)
        return SendClientMessage(playerid,COLOR_GRAD2," Veiculo sem Combustivel");
        if(LigadoDesligado2[vid] == 1)
        {
            motor[playerid] = 1;
        }
        if(LigadoDesligado2[vid] == 0)
        {
            motor[playerid] = 0;
        }
        if(carro != INVALID_VEHICLE_ID)
        {
            if(motor[playerid] == 0)
            {
                GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
                SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
                motor[playerid] = 1;
                LigadoDesligado2[carro] = 1;
                SendClientMessage(playerid, COLOR_WHITE, "Motor do veiculo ligado");
            }
            else
            {
                GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
                SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
                motor[playerid] = 0;
                LigadoDesligado2[carro] = 0;
                SendClientMessage(playerid, COLOR_WHITE, "Motor do veiculo desligado");
            }
        }
        return 1;
    }
Reply
#2

Tenta ai

pawn Код:
//Topo
new motor[MAX_VEHICLES];
new LigadoDesligado2[MAX_VEHICLES] = 0;

stock LigadoDesligado(carid)//desativado
{
    new txt[20];
    if(LigadoDesligado2[carid] == 0)
    {
        format(txt, sizeof(txt),"~r~Desligado");
    }
    else if(LigadoDesligado2[carid] == 1)
    {
        format(txt, sizeof(txt),"Ligado");
    }
    return txt;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    motor[playerid] = 0;
    new string[256];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* %s Entrou no Veнculo.", sendername);
    ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    if(Trancado[vehicleid] >= 1)
    {
        if(PlayerInfo[playerid][pAdmin] > 0 || ispassenger) { }
        else
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            SetPlayerPos(playerid, x, y, z+0.3);
            SetPlayerFacingAngle(playerid, a);
            SendClientMessage(playerid, COLOR_YELLOW, "Veiculo Trancado!");
        }
    }
    return true;
}
//Comando
    if(strcmp("/motor",cmdtext,true,6)==0)
    {
        new motorista = GetPlayerState(playerid);
        if(!IsPlayerInAnyVehicle(playerid) &&  motorista !=  PLAYER_STATE_DRIVER))
        {
            SendClientMessage(playerid,COLOR_GREY,"Vocк precisa estar em um veнculo!");
            return 1;
        }
        new mot, lu, alar, por, cap, porma, ob;
        new carro = GetPlayerVehicleID(playerid);

        new vid = GetPlayerVehicleID(playerid);
        if(Gas[vid] == 0)
        return SendClientMessage(playerid,COLOR_GRAD2," Veiculo sem Combustivel");
        if(LigadoDesligado2[vid] == 1)
        {
            motor[carro] = 1;
        }
        if(LigadoDesligado2[vid] == 0)
        {
            motor[carro] = 0;
        }
        if(carro != INVALID_VEHICLE_ID)
        {
            if(motor[carro] == 0)
            {
                GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
                SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
                motor[carro] = 1;
                LigadoDesligado2[carro] = 1;
                SendClientMessage(playerid, COLOR_WHITE, "Motor do veiculo ligado");
            }
            else
            {
                GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
                SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
                motor[carro] = 0;
                LigadoDesligado2[carro] = 0;
                SendClientMessage(playerid, COLOR_WHITE, "Motor do veiculo desligado");
            }
        }
        return 1;
    }
Reply
#3

Nгo funcionou !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)