hlmod.hu
https://hlmod.hu/

Random item drop
https://hlmod.hu/viewtopic.php?f=9&t=31215
Oldal: 1 / 1

Szerző:  The Peace [ 2022.01.14. 15:04 ]
Hozzászólás témája:  Random item drop

Sziasztok!

Egy olyan kérdésem lenne, hogy miért nem oda drop-ol ahol megölöm az embert? (RANDOM HELYEKRE)
[Lehet bezavar, hogy DR szerveren akarom? | Entity vagy valami bezavar neki?]
  1. public XpDobas()
  2. {  
  3.     new victim = read_data( 2 );
  4.    
  5.     static Float:origin[ 3 ];
  6.     pev( victim, pev_origin, origin );
  7.    
  8.     new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );
  9.     origin[ 2 ] -= 36;
  10.     engfunc( EngFunc_SetOrigin, ent, origin );
  11.    
  12.     if( !pev_valid( ent ) )
  13.     {
  14.         return PLUGIN_HANDLED;
  15.     }
  16.    
  17.     set_pev( ent, pev_classname, "Xp" );
  18.     engfunc( EngFunc_SetModel, ent, Csomag[0] );
  19.     dllfunc( DLLFunc_Spawn, ent );
  20.     set_pev( ent, pev_solid, SOLID_BBOX );
  21.     set_pev( ent, pev_movetype, MOVETYPE_NONE );
  22.     engfunc( EngFunc_SetSize, ent, Float:{ -23.160000, -13.660000, -0.050000 }, Float:{ 11.470000, 12.780000, 6.720000 } );
  23.     engfunc( EngFunc_DropToFloor, ent );
  24.    
  25.     return PLUGIN_HANDLED;
  26. }
  27. public XpTouch(ent, id)
  28. {
  29.     if(pev_valid(ent))
  30.     {
  31.         new classname[ 32 ];
  32.         pev( ent, pev_classname, classname, charsmax( classname ) );
  33.        
  34.         if( !equal( classname, "Xp") )
  35.         {
  36.             return FMRES_IGNORED;
  37.         }
  38.         new nev[32]; get_user_name(id, nev, 31)
  39.        
  40.      
  41.         Adataim[Xp][id]+=5
  42.         print_color(0, "!g[S]tunt*!t  %s!y  talált +!g5%!y Xp-t!",  nev)
  43.    
  44.         engfunc( EngFunc_RemoveEntity, ent );
  45.     }
  46.     return FMRES_IGNORED
  47. }

Szerző:  FonoK [ 2022.01.14. 20:18 ]
Hozzászólás témája:  Re: Random item drop

  1. new const gGiftModels[][] = {
  2.     "models/targy1.mdl"
  3. };
  4.  
  5.  
  6.  
  7. public plugin_precache()
  8.     for(new i = 0; i < sizeof gGiftModels; i++) precache_model(gGiftModels[i]);
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. public EVENT_DeathMsg()
  17. {  
  18.     new iKiller = read_data(1);
  19.     new iVictim = read_data(2);
  20.  
  21.     if(!IS_PLAYER(iVictim)) return;
  22.  
  23.     remove_task(iVictim);
  24.  
  25.     if(iVictim == iKiller) return;
  26.  
  27.     new Float:flOrigin[3];
  28.     pev(iVictim, pev_origin, flOrigin);
  29.  
  30.     flOrigin[2] += -34.0;
  31.  
  32.     new Float:flAngles[3];
  33.     pev(iVictim, pev_angles, flAngles);
  34.  
  35.     new iEntity = engfunc(EngFunc_CreateNamedEntity, gInfoTarget);
  36.  
  37.     if(!pev_valid(iEntity)) return;
  38.  
  39.     set_pev(iEntity, pev_classname, szGiftClassname);
  40.     set_pev(iEntity, pev_angles, flAngles);
  41.  
  42.     engfunc(EngFunc_SetOrigin, iEntity, flOrigin);
  43.     engfunc(EngFunc_SetModel, iEntity, gGiftModels[random_num(0)]);
  44.  
  45.     ExecuteHam(Ham_Spawn, iEntity);
  46.  
  47.     set_pev(iEntity, pev_solid, SOLID_BBOX);
  48.     set_pev(iEntity, pev_movetype, MOVETYPE_NONE);
  49.     set_pev(iEntity, pev_nextthink, get_gametime() + 2.0);
  50.  
  51.     engfunc(EngFunc_SetSize, iEntity, Float:{ -23.160000, -13.660000, -0.050000 }, Float:{ 11.470000, 12.780000, 6.720000});
  52.     engfunc(EngFunc_DropToFloor, iEntity);
  53.  
  54.     return;
  55. }

Szerző:  DexoN [ 2022.01.15. 10:11 ]
Hozzászólás témája:  Re: Random item drop

Helló, nekem működött a te változatoddal, szerintem ezeket megpróbálhatnád:
  • Csinálsz egy stockot, ami készít neked egy beampoint-ot a halottnál, illetve egy üzenettel kiíratod az originjét, amit többször eljátszol a kódrész végéig
  • Megnézheted ezzel a kóddal (benne van a stock is):

Kód:
new g_dot;

public plugin_precache() g_dot = precache_model("sprites/dot.spr");

public Deathmsg()

    new victim = read_data( 2 );
   
    static Float:origin[ 3 ];
    pev( victim, pev_origin, origin );
    ex_OriginInfo(origin, 255, 0, 0)

    new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );
    origin[ 2 ] -= 36.0;

    if( !pev_valid( ent ) )
    {
        return PLUGIN_HANDLED;
    }
   
    set_pev( ent, pev_classname, "Xp" );
    engfunc( EngFunc_SetModel, ent, Csomag[0] );
    set_pev( ent, pev_solid, SOLID_BBOX );
    set_pev( ent, pev_movetype, MOVETYPE_NONE );
    engfunc( EngFunc_SetSize, ent, Float:{ -23.160000, -13.660000, -0.050000 }, Float:{ 11.470000, 12.780000, 6.720000 } );
    ex_OriginInfo(origin, 0, 255, 0)
    set_pev(ent, pev_origin, origin)
    ex_OriginInfo(origin, 0, 0, 255)

    return PLUGIN_HANDLED;
}

stock ex_OriginInfo(Float:fOrigin[3], r, g, b){
    client_print_color(0,0,"^4x: %.2f ^3| ^4y: %.2f ^3| ^4z: %.2f", fOrigin[0], fOrigin[1], fOrigin[2])

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_BEAMPOINTS)

    write_coord(floatround(fOrigin[0]))
    write_coord(floatround(fOrigin[1]))
    write_coord(floatround(fOrigin[2]))

    write_coord(floatround(fOrigin[0]))
    write_coord(floatround(fOrigin[1]))
    write_coord(floatround(fOrigin[2]+60.0))

    write_short(g_dot)

    write_byte(1)
    write_byte(1)
    write_byte(1000)
    write_byte(5)
    write_byte(0)

    write_byte(r)
    write_byte(g)
    write_byte(b)

    write_byte(200)

    write_byte(0)

    message_end()
}

Szerintem alapból rossz origint kapsz meg, lehet egy másik script/kódrész megváltoztatja ez a script/kódrész előtt

Szerző:  The Peace [ 2022.01.15. 14:59 ]
Hozzászólás témája:  Re: Random item drop

DexoN írta:
Helló, nekem működött a te változatoddal, szerintem ezeket megpróbálhatnád:
  • Csinálsz egy stockot, ami készít neked egy beampoint-ot a halottnál, illetve egy üzenettel kiíratod az originjét, amit többször eljátszol a kódrész végéig
  • Megnézheted ezzel a kóddal (benne van a stock is):

Kód:
new g_dot;

public plugin_precache() g_dot = precache_model("sprites/dot.spr");

public Deathmsg()

    new victim = read_data( 2 );
   
    static Float:origin[ 3 ];
    pev( victim, pev_origin, origin );
    ex_OriginInfo(origin, 255, 0, 0)

    new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );
    origin[ 2 ] -= 36.0;

    if( !pev_valid( ent ) )
    {
        return PLUGIN_HANDLED;
    }
   
    set_pev( ent, pev_classname, "Xp" );
    engfunc( EngFunc_SetModel, ent, Csomag[0] );
    set_pev( ent, pev_solid, SOLID_BBOX );
    set_pev( ent, pev_movetype, MOVETYPE_NONE );
    engfunc( EngFunc_SetSize, ent, Float:{ -23.160000, -13.660000, -0.050000 }, Float:{ 11.470000, 12.780000, 6.720000 } );
    ex_OriginInfo(origin, 0, 255, 0)
    set_pev(ent, pev_origin, origin)
    ex_OriginInfo(origin, 0, 0, 255)

    return PLUGIN_HANDLED;
}

stock ex_OriginInfo(Float:fOrigin[3], r, g, b){
    client_print_color(0,0,"^4x: %.2f ^3| ^4y: %.2f ^3| ^4z: %.2f", fOrigin[0], fOrigin[1], fOrigin[2])

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_BEAMPOINTS)

    write_coord(floatround(fOrigin[0]))
    write_coord(floatround(fOrigin[1]))
    write_coord(floatround(fOrigin[2]))

    write_coord(floatround(fOrigin[0]))
    write_coord(floatround(fOrigin[1]))
    write_coord(floatround(fOrigin[2]+60.0))

    write_short(g_dot)

    write_byte(1)
    write_byte(1)
    write_byte(1000)
    write_byte(5)
    write_byte(0)

    write_byte(r)
    write_byte(g)
    write_byte(b)

    write_byte(200)

    write_byte(0)

    message_end()
}

Szerintem alapból rossz origint kapsz meg, lehet egy másik script/kódrész megváltoztatja ez a script/kódrész előtt



Köszönöm, meglesem és jogos!

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/