[AJU]Key movimentar objeto
#1

Estou fazendo meu FS do Exercito (finalmente), ai criei um navio, ate aн tudo certo, ai criei variaveis para definirem os objetos do navio, e as outras:
pawn Код:
new Navio[20];
new DirigindoNavio[MAX_PLAYERS];
new PortaDaCabine;
Atй ai tambem esta tudo certo, ai defini os objetos (OnGameModeInit):
pawn Код:
Navio[1] = CreateObject(10771,885.19287109,-2979.91235352,3.60642958,0.00000000,0.00000000,0.00000000); //object(carrier_hull_sfse) (1) navio
    Navio[2] = CreateObject(11145,819.40930176,-2980.10034180,2.65397930,0.00000000,0.00000000,0.00000000); //object(carrier_lowdeck_sfs) (1) navio
    Navio[3] = CreateObject(10770,888.35449219,-2987.49316406,36.78397369,0.00000000,0.00000000,0.00000000); //object(carrier_bridge_sfse) (1) navio
    Navio[4] = CreateObject(11146,876.20745850,-2979.27954102,10.40734959,0.00000000,0.00000000,0.00000000); //object(carrier_hangar_sfs) (1) navio
    Navio[5] = CreateObject(11237,887.84484863,-2987.48022461,36.67521667,0.00000000,0.00000000,0.00000000); //object(carrier_bits_sfse) (1) navio
    Navio[6] = CreateObject(3115,786.14044189,-2979.84643555,8.08432961,0.00000000,0.00000000,180.64996338); //object(carrier_lift1_sfse) (1)pode subir navio
    Navio[7] = CreateObject(3114,828.43194580,-2964.96801758,7.81825066,0.00000000,0.00000000,0.00000000); //object(carrier_lift2_sfse) (1) pode subir tambem navio
    Navio[8] = CreateObject(2634,895.07348633,-2982.04980469,16.93971634,0.00000000,0.00000000,0.00000000); //object(ab_vaultdoor) (1) navio
    Navio[9] = CreateObject(2634,897.66278076,-2980.06323242,10.01470757,0.00000000,0.00000000,0.00000000); //object(ab_vaultdoor) (2) navio
    Navio[10] = CreateObject(2634,902.15283203,-2983.20605469,9.73971176,0.00000000,180.56996155,269.68997192); //object(ab_vaultdoor) (3) navio
    Navio[11] = CreateObject(3884,909.93994141,-2987.72216797,26.49646378,0.00000000,0.00000000,270.67504883); //object(samsite_sfxrf) (1) navio
    Navio[12] = CreateObject(3790,910.59423828,-2988.38525391,29.14423943,0.00000000,151.44006348,0.00000000); //object(missile_01_sfxr) (1) missel navio
    Navio[13] = CreateObject(3790,910.89074707,-2988.37744141,28.71923828,0.00000000,151.43554688,0.00000000); //object(missile_01_sfxr) (3) missel navio
    Navio[14] = CreateObject(967,910.74450684,-2983.59521484,18.35428619,0.00000000,0.00000000,0.00000000); //object(bar_gatebox01) (1) cabine navio
    Navio[15] = CreateObject(1473,903.86267090,-2981.02929688,15.63841248,0.00000000,0.00000000,272.65997314); //object(dyn_porch_1b) (1) navio
    Navio[16] = CreateObject(1473,905.61047363,-2980.94311523,16.48841095,0.00000000,0.00000000,272.65869141); //object(dyn_porch_1b) (2) navio
    Navio[17] = CreateObject(1473,907.32965088,-2980.84570312,17.28841019,0.00000000,0.00000000,272.65869141); //object(dyn_porch_1b) (3) navio
    Navio[18] = CreateObject(1473,909.00427246,-2980.82495117,18.03841782,0.00000000,0.00000000,272.65869141); //object(dyn_porch_1b) (4)navio
    Navio[19] = CreateObject(1473,910.45617676,-2981.24072266,18.31341362,336.18005371,0.00000000,272.65869141); //object(dyn_porch_1b) (6) navio

Entгo criei os comandos:
pawn Код:
if (strcmp("/entrarnavio", cmdtext, true, 10) == 0)
    {
    if(DirigindoNavio[playerid] == 0) {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 910.74450684,-2983.59521484,18.35428619)) {
            SendClientMessage(playerid, AZUL, "Vocк estб dirigindo o navio !!!");
            //new PlayerName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
            new string[60];
            format(string, sizeof(string), "%s estб dirigindo o navio", PlayerName);
            print(string);
            TogglePlayerControllable(playerid, false);
            DirigindoNavio[playerid] = 1;
            PortaDaCabine = CreateObject(991,908.16186523,-2982.80712891,19.41952896,0.00000000,0.00000000,0.00000000);//object(bar_barriergate1) (1) criar quando o player esta dirigindo navio
        }
        else
        {
            SendClientMessage(playerid, VERMELHO, "Vocк nгo estб na cabine do navio");
        }
    }
    else
    {
        SendClientMessage(playerid, VERMELHO, "Vocк jб estб dirigindo o navio");
    }
    return 1;
}

    if (strcmp("/sairnavio", cmdtext, true, 10) == 0)
    {
        if(DirigindoNavio[playerid] == 0)
        {
            SendClientMessage(playerid, VERMELHO, "Vocк nгo estб pilotando o navio");
        }
        else if(DirigindoNavio[playerid] == 1)
        {
            DestroyObject(PortaDaCabine);
            DirigindoNavio[playerid] = 0;
            TogglePlayerControllable(playerid, true);
        }
        return 1;
    }
Ai tambйm estб funcionando corretamente. Ai fiz as partes de mover o navio com teclas:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:X;
    new Float:Y;
    new Float:Z;
    if((newkeys ==  KEY_WALK) || (newkeys ==  KEY_UP) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X+2, Y, Z, 8.0);
        return 1;
    }
    if(((newkeys) ==  KEY_WALK) || (newkeys ==  KEY_UP) && (newkeys == KEY_RIGHT) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X+2, Y+2, Z, 8.0);
        return 1;
    }
    if(((newkeys) ==  KEY_DOWN) || (newkeys ==  KEY_DOWN) && (newkeys == KEY_LEFT) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X-2, Y-2, Z, 5.0);
        return 1;
    }
    if(((newkeys) ==  KEY_DOWN) || (newkeys ==  KEY_DOWN) && (newkeys == KEY_RIGHT) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X-2, Y+2, Z, 5.0);
        return 1;
    }
    return 1;
}
Mas o problema й que nгo move nenhum objeto.
Reply
#2

й logico olha a cordenada que vc quer mover os objetos...
Reply
#3

tem alguma soluзгo entao?
Reply
#4

estб tudo errado ...

peque isto https://sampwiki.blast.hk/wiki/GetObjectPos

Estu-deo!
Reply
#5

entao vou ter que pegar a pos de cada Navio[numero] ??
Reply
#6

@Garfield:
Nгo esta Tudo errado,ele precisa Apenas de um GetPos para arrumar tudo isso..

@BieL:
Cara vocк nгo deve achar que seu trabalho esta errado por opiniгo de outros,FikDik

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:X;
    new Float:Y;
    new Float:Z;
    GetObjectPos(Navio[19], X, Y, Z);
    if((newkeys ==  KEY_WALK) || (newkeys ==  KEY_UP) && (DirigindoNavio[playerid] = 1))
    {
       
        MoveObject(Navio[19], X+2, Y, Z, 8.0);
        return 1;
    }
    if(((newkeys) ==  KEY_WALK) || (newkeys ==  KEY_UP) && (newkeys == KEY_RIGHT) && (DirigindoNavio[playerid] = 1))
    {
         
        MoveObject(Navio[19], X+2, Y+2, Z, 8.0);
        return 1;
    }
    if(((newkeys) ==  KEY_DOWN) || (newkeys ==  KEY_DOWN) && (newkeys == KEY_LEFT) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X-2, Y-2, Z, 5.0);
        return 1;
    }
    if(((newkeys) ==  KEY_DOWN) || (newkeys ==  KEY_DOWN) && (newkeys == KEY_RIGHT) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X-2, Y+2, Z, 5.0);
        return 1;
    }
    return 1;
}
Caso nгo de Tente:


pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:X;
    new Float:Y;
    new Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if((newkeys ==  KEY_WALK) || (newkeys ==  KEY_UP) && (DirigindoNavio[playerid] = 1))
    {
       
        MoveObject(Navio[19], X+2, Y, Z, 8.0);
        return 1;
    }
    if(((newkeys) ==  KEY_WALK) || (newkeys ==  KEY_UP) && (newkeys == KEY_RIGHT) && (DirigindoNavio[playerid] = 1))
    {
         
        MoveObject(Navio[19], X+2, Y+2, Z, 8.0);
        return 1;
    }
    if(((newkeys) ==  KEY_DOWN) || (newkeys ==  KEY_DOWN) && (newkeys == KEY_LEFT) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X-2, Y-2, Z, 5.0);
        return 1;
    }
    if(((newkeys) ==  KEY_DOWN) || (newkeys ==  KEY_DOWN) && (newkeys == KEY_RIGHT) && (DirigindoNavio[playerid] = 1))
    {
        MoveObject(Navio[19], X-2, Y+2, Z, 5.0);
        return 1;
    }
    return 1;
}
@EDIT:
Uma linha alн pode arrumar Tudo Creio... (GetPos
Reply
#7

pois й drakon, botei assim e testei, nao moveu, sera q eh a velocidade, ou a pos q ele seta?
Reply
#8

Coloca assim em algum deles:

pawn Код:
print("Funcionou");
Use aquele que vocк fez isso, se aparecer no log do server, essa mensagem (no console), quer dizer que o problema estб no MoveObject
Reply
#9

Quote:
Originally Posted by SuB_ZeRo0_
Посмотреть сообщение
Coloca assim em algum deles:

pawn Код:
print("Funcionou");
Use aquele que vocк fez isso, se aparecer no log do server, essa mensagem (no console), quer dizer que o problema estб no MoveObject
:O, kkkkkkkk, metodo velho, uso muito ele, ok vou testar
Reply
#10

Se o navio for isso tudo ai, vai ser meio dificil ele se mover sem parecer estar se quebrando, pois vocк teria que fazer um loop, e o loop nгo й tгo rбpido a esse ponto. Tente fazer, talvez o loop garanta um movimento sincronizado a esses objetos aн, se nгo ficar bom, desista, sу com um objeto ъnico mesmo.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)