AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ent[33] Don't work -> Need Array help, or someting like that. (https://forums.alliedmods.net/showthread.php?t=127156)

Xalus 05-17-2010 14:47

Ent[33] Don't work -> Need Array help, or someting like that.
 
So:

I tryed with: Ent[ent] = 1
But: Wrecked_ said: [33] is only for Players.

So can somoene make an example or say how I need make it then?
With Array:ent or something he said, I dunno.


Thanks!

Exolent[jNr] 05-17-2010 14:51

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
You want an array that uses entities to index it?

Xalus 05-17-2010 14:52

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
ye I think xD

Ent = ArrayCreate()

Wrecked said something like that

Exolent[jNr] 05-17-2010 14:55

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
It's not smart to have an array to be indexed by entities, since entity indexes can range to 2000 or more.

It would be better to use special entity values, like pev_[i|f|v|e]user[1|2|3|4].

Xalus 05-17-2010 14:56

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
ye but I need set the Target of the button to 1
so: ent[target] 1

That don't work with pevs?

Exolent[jNr] 05-17-2010 15:00

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
Describe what you are trying to do in the plugin instead of this simple array so we can discuss solutions from better understanding the situation.

grimvh2 05-17-2010 15:04

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
Quote:

Originally Posted by Xalus (Post 1183421)
But: Wrecked_ said: [33] is only for Players.

wrong

Xalus 05-17-2010 15:47

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
I tested it with 33,

First buttons worked, en the rest not

Sylwester 05-17-2010 17:22

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
Quote:

Originally Posted by Xalus (Post 1183426)
ye I think xD

Ent = ArrayCreate()

Wrecked said something like that

Check cellarray.inc in your scripting/include folder.

Or you can use something like this:
PHP Code:

#define MAX_BUTTONS 30

new g_list[MAX_BUTTONS]
new 
g_list_num
new g_target[MAX_BUTTONS]

public 
set_button_target(ent_idtarget_id){
    for(new 
i=0i<g_list_numi++){
        if(
g_list[i] != ent_id)
            continue
        
g_target[i] = target_id
        
return
    }
    if(
g_list_num>=MAX_BUTTONS)
        return
    
g_targetg_list_num ] = target_id
    g_list
g_list_num++ ] = ent_id
}


public 
del_button(ent_id){
    if(
g_list_num<=0)
        return
    for(new 
i=0i<g_list_numi++){
        if(
g_list[i] != ent_id)
            continue
        
g_target[i] = g_target[ --g_list_num ]
        
g_list[i] = g_listg_list_num ]
        return
    }
}


public 
get_button_target(ent_id){
    if(
g_list_num<=0)
        return -
1
    
for(new i=0i<g_list_numi++){
        if(
g_list[i] != ent_id)
            continue
        return 
g_target[i]
    }
    return -
1



Exolent[jNr] 05-17-2010 17:59

Re: Ent[33] Don't work -> Need Array help, or someting like that.
 
@Sylwester
There is no reason for something like that.
Like I said, the pev values would be best for this situation.

Code:
#include < engine > const buttonval_target = EV_INT_iuser1; const buttonval_button = EV_INT_iuser2; set_button_target( iButton, iTarget ) {     new iOldTarget = entity_get_int( iButton, buttonval_target );         if( iOldTarget     &&  is_valid_ent( iOldTarget )     &&  entity_get_int( iOldTarget, buttonval_button ) == iButton )     {         entity_set_int( iOldTarget, buttonval_button, 0 );     }         entity_set_int( iButton, buttonval_target, iTarget );     entity_set_int( iTarget, buttonval_button, iButton ); } del_button( iButton ) {     new iTarget = entity_get_int( iButton, buttonval_target );         if( iTarget )     {         if( is_valid_ent( iTarget )         &&  entity_get_int( iTarget, buttonval_button ) == iButton )         {             entity_set_int( iTarget, buttonval_button, 0 );         }                 entity_set_int( iButton, buttonval_target, 0 );     } } get_button_target( iButton ) {     return entity_get_int( iButton, buttonval_target ); }


All times are GMT -4. The time now is 03:51.

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