AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Cache_UnlinkLRU: NULL link (https://forums.alliedmods.net/showthread.php?t=226069)

Randomize 09-13-2013 09:05

Cache_UnlinkLRU: NULL link
 
The CS crashed when someone change to the primary, Cache_UnlinkLRU: NULL link. What causes that?

PHP Code:

public cmd_backweapon(id)
{
    new 
players[32], playersnum
    get_players
(playersplayersnum"a")
    
    for (new 
playersnum ; ++i)
    {
        
backweapon[i] = create_entity("info_target")
        
entity_set_edict(backweapon[i], EV_ENT_owneri)
        
entity_set_edict(backweapon[i], EV_ENT_aimenti)
        
entity_set_int(backweapon[i], EV_INT_movetypeMOVETYPE_FOLLOW)
        
entity_set_model(backweapon[i], "models/backweapons.mdl")
    }


CurWeapon event:
PHP Code:

if (<< get_user_weapon(id) & OTHERS)
    {
        
set_pev(backweapon[id], pev_bodycurrent_weapon[id])
    }
    else
    {
        
set_pev(backweapon[id], pev_body0)
    } 


Randomize 09-22-2013 01:39

Re: Cache_UnlinkLRU: NULL link
 
bump

ConnorMcLeod 09-22-2013 11:30

Re: Cache_UnlinkLRU: NULL link
 
Your get_players usage is not correct.

Suppose there are 5 players.

You use indexes 1 2 3 4 5, but connected players could have indexes 2 5 10 15 16

In that case, players array would contain :

players[0] -> 2
players[1] -> 5
players[2] -> 10
players[3] -> 15
players[4] -> 16

So to retrieve player index in the loop, you have to do players[i]
Also, a good habit is to cache such values when you need it more than once

So instead of doing :

PHP Code:

        player players[i]
        
entity_set_edict(backwpnEV_ENT_ownerplayers[i])
        
entity_set_edict(backwpnEV_ENT_aimentplayers[i]) 

do

PHP Code:

        entity_set_edict(backwpnEV_ENT_ownerplayer)
        
entity_set_edict(backwpnEV_ENT_aimentplayer

And do the same for backweapon[i] that is used 5 times.

So correct code is :

Code:
public cmd_backweapon(id) {     new players[32], playersnum     get_players(players, playersnum, "a")     new player, backwpn     for (new i = 0 ; i < playersnum ; ++i)     {         player = players[i]         backweapon[i] = backwpn = create_entity("info_target")         entity_set_edict(backwpn, EV_ENT_owner, player)         entity_set_edict(backwpn, EV_ENT_aiment, player)         entity_set_int(backwpn, EV_INT_movetype, MOVETYPE_FOLLOW)         entity_set_model(backwpn, "models/backweapons.mdl")     } }

Randomize 09-23-2013 09:31

Re: Cache_UnlinkLRU: NULL link
 
It didn't retrieve correctly, I tried to give:
PHP Code:

client_print(iprint_chat"%i"backweapon[i]) 

and it printed twice.
44
45

so the actual entity id is 44 but set to 45. So I must make the entity id to 44 by using:
PHP Code:

backweapon[id] - 


ConnorMcLeod 09-24-2013 00:20

Re: Cache_UnlinkLRU: NULL link
 
Are you kidding me ?


All times are GMT -4. The time now is 19:14.

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