Raised This Month: $51 Target: $400
 12% 

array must be indexed ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
undead52
Senior Member
Join Date: Dec 2016
Old 11-26-2017 , 10:31   array must be indexed ?
Reply With Quote #1

PHP Code:
    new szName[32
    
get_user_name(idszNamecharsmax(szName)) 
    
set_dhudmessage153204255,-1.00.101.01.0 );
    
show_dhudmessage(id"[ %d / %d ]"gKill[szName], buyuk
wht cant use gKill[szName]

says array must be indexed ?

Last edited by undead52; 11-26-2017 at 10:36.
undead52 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 11-26-2017 , 10:39   Re: array must be indexed ?
Reply With Quote #2

szName is a string and you're trying to set the gKill array size to a string.
Like gKill["Player"]... no sense-io.

Show your full code and describe your thread with more details.
__________________
Relaxing is offline
undead52
Senior Member
Join Date: Dec 2016
Old 11-26-2017 , 10:44   Re: array must be indexed ?
Reply With Quote #3

thats what i trying to,but it doesnt work properly

PHP Code:
public hud(id){
 
    
set_dhudmessage153204255,    -1.00.101.01.0 );
    
show_dhudmessage(id"[ %d / %d ]"gKill[id], buyuk)//problem
 
 
}

public 
event_death(id)
{
    if(
scor == 1){
        new 
Killerplayers[32], pnumisim[32];
        
        
Killer read_data(1)
        
gKill[Killer]++;//problem is here too i dont wanna do that on Killer, want to do on Killer name
        
        
get_playersplayerspnum );
        
        for ( new 
ipnumi++ ){

                    
                if(
gKill[Killer] > buyuk){
                
                    
buyuk gKill[Killer];
            
                
                }
            }        

    }


Last edited by undead52; 11-26-2017 at 10:44.
undead52 is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 11-26-2017 , 10:44   Re: array must be indexed ?
Reply With Quote #4

Quote:
gKill[szName]
not an "array index", you must tried to use id (clientId) instead szName
szName is a char(string), arrays' indexes are real numbers as integer(1,2,3,4) only

Last edited by ZASTRELIS; 11-26-2017 at 10:51.
ZASTRELIS is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 11-26-2017 , 10:45   Re: array must be indexed ?
Reply With Quote #5

Array[size of matrix] (
...
data as {matrixs' vector}
...
)

Last edited by ZASTRELIS; 11-26-2017 at 10:47.
ZASTRELIS is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 11-26-2017 , 10:47   Re: array must be indexed ?
Reply With Quote #6

array

0 0 0 0
0 1 0 0

same as

Array[2][4]

You can access to 1 only if told to what position in. One in Array[1][1] = 1;

Each count in arrays starts from 0, not from 1.

https://wiki.alliedmods.net/Pawn_Tutorial#Arrays

Last edited by ZASTRELIS; 11-26-2017 at 10:49.
ZASTRELIS is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 11-26-2017 , 10:56   Re: array must be indexed ?
Reply With Quote #7

use for buyuk
Code:
static name[32][32]; get_user_name(id, name[id], 31)

and you can tried to show it in
Code:
show_dhudmessage(id, "[ %d / %d ] %s", gKill[id], name[id]) //ChatBot[VIP]: [ 1 / 1 ] Player

p.s. remember that // [32]*[32] = 1024bytes/1Kb of Ram)))

Last edited by ZASTRELIS; 11-26-2017 at 11:03.
ZASTRELIS is offline
undead52
Senior Member
Join Date: Dec 2016
Old 11-26-2017 , 11:01   Re: array must be indexed ?
Reply With Quote #8

gKill[id] is shows empty, because gKill[Killer] and gKill[id] is not same, i cant show it , thats the problem, gKill[killer] player score buyuk is the highest score,buyuk works fine but gKill[Killer] always show 0

if i could on killer name or something else there will no problem

Last edited by undead52; 11-26-2017 at 11:03.
undead52 is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 11-26-2017 , 11:02   Re: array must be indexed ?
Reply With Quote #9

what you wanna to do?)
ZASTRELIS is offline
undead52
Senior Member
Join Date: Dec 2016
Old 11-26-2017 , 11:05   Re: array must be indexed ?
Reply With Quote #10

PHP Code:
        Killer read_data(1)
        
gKill[Killer]++;//i shouldnt get on Killer , if i could do gKill[szName],i could print it too on dhudmessage, but i cant because gKill[Killer] dont work or id 
i guess i need somethink special to player but not string

realize

PHP Code:
Killer read_data(1)

something get_........(Killer)//something shouldnt be string.

gKill[something]++;

show_dhudmessage(id"[ %d / %d ]"gKill[something], buyuk
then i can show it,but cant show Killer, thats the problem

Last edited by undead52; 11-26-2017 at 11:20.
undead52 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:27.


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