[Include] w!hook - (beta)
#21

@Atualizado.

OBS: Para quem estiver utilizando a include, peзo que atualize logo para esta nova versгo, pois eu corrigi um bug que estava ocorrendo durante as chamadas.

Info update[13/10/2013]:
Fiz algumas modificaзхes na sintaxe como havia prometido, nгo foi algo que chegasse perto do nosso padrгo visual de atualmente, mas fiz algo que acredite que vб simplificar bastante, o uso ficou mais simples que a versгo antiga, vejamos:

Agora podemos fazer o hook de uma forma mais agradбvel e fбcil de se aprender:
pawn Code:
//include
hook_s::funct()
{
    print("hookeada");

    call->funct();
}
A include permanece na mesma forma de criaзгo de hook, o interessante vem na parte GM:
pawn Code:
register <stock>funct()
{
    print("original");
}
Interessante, nгo ? usei a palavra reservada 'register' para indicar que vocк estб hookeando uma funзгo nova, seja ela stock ou forward/public, isto й indicado no < stock > ou < public >

Exemplo de hook nativo:
pawn Code:
//include
hook_f::OnGameModeInit()
{
    print("hookeada");
   
    call->OnGameModeInit();
   
    return nop;
}

//GM
register <public>OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
   
    print("[DEBUG / GM] Callback: OnGameModeInit called");
   
    AddStaticVehicleEx(520,2494.8999000,-1669.3000500,14.3000000,0.0000000,141,141,300); //Hydra
    AddStaticVehicleEx(432,277.8999900,1955.6999500,17.7000000,270.0000000,141,141,300); //Rhino
    AddStaticVehicleEx(432,277.1000100,1989.5999800,17.7000000,270.0000000,141,141,300); //Rhino
    AddStaticVehicleEx(432,277.2000100,2023.5999800,17.7000000,270.0000000,141,141,300); //Rhino
    AddStaticVehicleEx(520,300.2999900,2051.1001000,18.6000000,180.0000000,141,141,300); //Hydra
    AddStaticVehicleEx(520,314.0000000,2051.3000500,18.6000000,180.0000000,141,141,300); //Hydra
    AddStaticVehicleEx(548,281.5000000,1929.9000200,19.5000000,270.0000000,141,141,300); //Cargobob
    AddStaticVehicleEx(425,316.2999900,1805.5000000,18.5000000,0.0000000,141,141,300); //Hunter
    AddStaticVehicleEx(425,303.5000000,1805.4000200,18.5000000,0.0000000,141,141,300); //Hunter
    AddStaticVehicleEx(470,220.3000000,1920.5999800,17.8000000,180.0000000,141,141,300); //Patriot
    AddStaticVehicleEx(470,211.8000000,1920.5999800,17.8000000,180.0000000,141,141,300); //Patriot
    AddStaticVehicleEx(470,202.3999900,1920.6999500,17.8000000,178.2710000,141,141,300); //Patriot
    AddStaticVehicleEx(470,193.3999900,1920.6999500,17.8000000,180.3630000,141,141,300); //Patriot
    AddStaticVehicleEx(468,201.8000000,1814.5999800,17.4000000,0.0000000,141,141,300); //Sanchez
    AddStaticVehicleEx(468,200.3000000,1814.6999500,17.4000000,0.0000000,141,141,300); //Sanchez
    AddStaticVehicleEx(433,278.7999900,1788.3000500,18.2000000,0.0000000,141,141,300); //Barracks
    AddStaticVehicleEx(433,283.8999900,1788.5000000,18.2000000,0.0000000,141,141,300); //Barracks
    AddStaticVehicleEx(433,-1240.3000500,438.7999900,7.8000000,0.0000000,141,141,300); //Barracks
    AddStaticVehicleEx(433,-1232.3000500,438.6000100,7.8000000,0.0000000,141,141,300); //Barracks
    AddStaticVehicleEx(470,-1384.0999800,455.2000100,7.3000000,0.0000000,141,141,300); //Patriot
    AddStaticVehicleEx(470,-1389.9000200,455.3999900,7.3000000,0.0000000,141,141,300); //Patriot
    AddStaticVehicleEx(470,-1396.0000000,455.6000100,7.3000000,0.0000000,141,141,300); //Patriot
    AddStaticVehicleEx(470,-1402.3000500,455.6000100,7.3000000,0.0000000,141,141,300); //Patriot
    AddStaticVehicleEx(520,-1267.0999800,498.2999900,19.2000000,271.1220000,141,141,300); //Hydra
    AddStaticVehicleEx(520,-1301.6999500,507.6000100,19.2000000,271.1220000,141,141,300); //Hydra
    AddStaticVehicleEx(425,-1415.3000500,493.1000100,19.1000000,271.1220000,141,141,300); //Hunter
    AddStaticVehicleEx(425,-1425.8000500,507.8999900,19.1000000,271.1220000,141,141,300); //Hunter
    AddStaticVehicleEx(548,-1360.5999800,507.8999900,20.1000000,271.1220000,141,141,300); //Cargobob
    AddStaticVehicleEx(432,-1466.0999800,457.7000100,7.3000000,0.0000000,141,141,300); //Rhino
    AddStaticVehicleEx(432,-1454.5000000,457.2000100,7.3000000,0.0000000,141,141,300); //Rhino
    AddStaticVehicleEx(468,-1526.5999800,483.5000000,6.9000000,0.0000000,141,141,300); //Sanchez
    AddStaticVehicleEx(468,-1533.6999500,483.3999900,6.9000000,0.0000000,141,141,300); //Sanchez
   
   
    return 1;
}
Com essa atualizaзгo nгo haverб mais bugs na chamada, e vocкs poderгo trabalhar de uma forma bastante simplificada.

Include source:
pawn Code:
/*
*
*   HOOK v1 beta - Willian_Luigi
*   Data de inicio: 08/10/2013
*   Ultima atualizaзгo: 13/10/2013
*   CODE.ME, 2013.1 -
*
*/

#if defined _whooks_included
  #endinput
#endif
#define _whooks_included
#pragma library whooks
#define hook_f::%0(%1) public %0(%1) <>
#define hook_s::%0(%1) stock %0(%1) <>
#define function::%0(%1) public %0(%1) <hook:_%0>
#define sstock::%0(%1) %0(%1) <hook:_%0>
#define register<%0>%1(%2) %0 %1(%2) <hook:_%1>
#define call->%0(%1) state hook:_%0; %0(%1)
#define nop (0x90)
#define NOP nop
Abraзos.
Reply
#22

Boa!
Reply
#23

ahahah agr sim

agr ta mt melhor
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)