[Ajuda] Otimizaзгo desde cуdigo
#1

pawn Code:
public OnPlayerUpdate(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInArea(playerid, 1008,1632,1212,1806))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            armasAtivadas = false;
        }
    }
    else
    {
        armasAtivadas = true;
        if(armasAtivadas == true)
        {
            if(GetVehicleModel(vehicleid) == 415)
            {

                Bazuca1 = CreateObject(360, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                Bazuca2 = CreateObject(360, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                Minigun1 = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                Minigun2 = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

                AttachObjectToVehicle(Bazuca1, vehicleid, 1026.5,1795.4,10.8,0.0,0.0,0.0);
                AttachObjectToVehicle(Bazuca2, vehicleid, 0.2, -0.2, 0.7, 0.0, 0.0, 90.0);
                AttachObjectToVehicle(Minigun1, vehicleid, 0.0, 0.0, 0.7, 0.0, 0.0, 90.0);
                AttachObjectToVehicle(Minigun2, vehicleid, -0.2, -0.2, 0.7, 0.0, 0.0, 90.0);
                return 1;
            }
        }
    }
    return true;
}
Sу que a OnPlayerUpdate й chamada vбrias vezes por segundo nй ? E isso simplesmente laga o servidor deixando injogavel...
O que eu queria saber era o seguinte: Qual a public eu posso usar pra deixar isso atualizando, seilб, 1 vez a cada 2 ou 3 segundos ? qual a public ?

fllws (:
Reply
#2

usa OnPlayerStateChange , somente atualiza quando o jogador entrar no veнculo, ou use timers.
Reply
#3

Tente assim:
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER){

        static vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
       
       
        if(IsPlayerInArea(playerid, 1008,1632,1212,1806)){
            if(IsPlayerInAnyVehicle(playerid)){
                armasAtivadas = false;
            }
        }
        else
        {
            armasAtivadas = true;
            if(armasAtivadas == true)
            {
                if(GetVehicleModel(vehicleid) == 415)
                {

                    Bazuca1 = CreateObject(360, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                    Bazuca2 = CreateObject(360, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                    Minigun1 = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                    Minigun2 = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

                    AttachObjectToVehicle(Bazuca1, vehicleid, 1026.5,1795.4,10.8,0.0,0.0,0.0);
                    AttachObjectToVehicle(Bazuca2, vehicleid, 0.2, -0.2, 0.7, 0.0, 0.0, 90.0);
                    AttachObjectToVehicle(Minigun1, vehicleid, 0.0, 0.0, 0.7, 0.0, 0.0, 90.0);
                    AttachObjectToVehicle(Minigun2, vehicleid, -0.2, -0.2, 0.7, 0.0, 0.0, 90.0);
                    return 1;
                }
            }
        }
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)