AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ H3LP ] Laser sight mistake? (https://forums.alliedmods.net/showthread.php?t=299929)

CrazY. 07-30-2017 16:19

[ H3LP ] Laser sight mistake?
 
Hello, I've done a laser sight, it's working but with some problems. As the item_PostFrame is called many times per second, they are appearing 4 lasers instead of just one. Any suggestions?

Code:
public fw_Item_PostFrame(entity) {     if (!is_valid_ent(entity))         return HAM_IGNORED;     static id     id = get_pdata_cbase(entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)     if (!is_user_alive(id))         return HAM_IGNORED;     if (!GetPlayerBit(g_has_plasma_caster, id))         return HAM_IGNORED;     static Float:victim_origin[3], victim     victim = get_aim_ent(id, victim_origin)     static Float:origin[3]     GetGunPosition(id, 3.0, -9.0, 0.0, origin)     static end[3]     if (victim)         FVecIVec(victim_origin, end)     else         get_user_origin(id, end, 3)     message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)     write_byte(TE_BEAMPOINTS)     write_coord(floatround(origin[0]))     write_coord(floatround(origin[1]))     write_coord(floatround(origin[2]))     write_coord(end[0])     write_coord(end[1])     write_coord(end[2])     write_short(sprite_laser)     write_byte(0)     write_byte(10)     write_byte(1)     write_byte(5)     write_byte(0)     write_byte(200)     write_byte(0)     write_byte(0)     write_byte(200)     write_byte(10)     message_end()     return HAM_IGNORED; }

Celena Luna 07-31-2017 05:56

Re: [ H3LP ] Laser sight mistake?
 
You can make a timestamps to how long do you another laser will be created

PHP Code:

new Float:g_Timestamps[33]

public 
fw_Item_PostFrame(entity)
{
    if (!
is_valid_ent(entity))
        return 
HAM_IGNORED;

    static 
id 
    id 
get_pdata_cbase(entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS)

    if(
g_Teamstamps[id] + 1.0 get_gametime()) //1 second
        
return HAM_IGNORED

    g_Timestamps
[id] = get_gametime()



Natsheh 07-31-2017 09:30

Re: [ H3LP ] Laser sight mistake?
 
And also change the beam point life time to 10 is 1 sec.

CrazY. 08-02-2017 18:31

Re: [ H3LP ] Laser sight mistake?
 
I tried to modify your code, but it's not working. My theory of what's going on:

Code:
new Float:g_Timestamps[33] = 0.0

Code:
if (g_Teamstamps[id] + 1.0 (0.0 + 1.0  = 1.0) < get_gametime() (suppose to be 2.0 or any other value greater than 1.0.)

Code:
Then, do nothing...

Celena Luna 08-11-2017 11:25

Re: [ H3LP ] Laser sight mistake?
 
Quote:

Originally Posted by Celena Luna (Post 2538828)
You can make a timestamps to how long do you another laser will be created

PHP Code:

new Float:g_Timestamps[33]

public 
fw_Item_PostFrame(entity)
{
    if (!
is_valid_ent(entity))
        return 
HAM_IGNORED;

    static 
id 
    id 
get_pdata_cbase(entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS)

    if(
g_Teamstamps[id] + 1.0 get_gametime()) //1 second
        
return HAM_IGNORED

    g_Timestamps
[id] = get_gametime()



Quote:

Originally Posted by Natsheh (Post 2538848)
And also change the beam point life time to 10 is 1 sec.

You need combine 2 reply not only 1


All times are GMT -4. The time now is 23:09.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.