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

Basic array error?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 11-11-2018 , 16:23   Basic array error?
Reply With Quote #1

Quote:
public FwdPlayerSpawnPost( id )
{
if( is_user_alive( id ) )
{
g_iCurrentKills[ id ] = 0

if( get_pcvar_num( g_iEnableShowSkillPointsOnNick ) )
{
new szName[ 32 ]
get_user_info( id, "name", szName, charsmax( szName ) )

new iLen = strlen( szName )

new iPos = iLen - 1

if( szName[ iPos ] == '>' )
{
new i
for( i = 1; i < 7; i++ )
{
if( szName[ iPos - i ] == '<' )
{
iLen = iPos - i
szName[ iLen ] = '^0'
break
}
}
}

format(szName[ iLen ], charsmax( szName ) - iLen, szName[ iLen-1 ] == ' ' ? "<%d>" : " <%d>", g_iPoints[ id ] )
new team[] = "Team1";
new team1[] = "Team2";
new teamz = get_user_team(id)
if(teamz == 1) {
set_user_info( id, "name", team+szName )
}
if(teamz == 2) {
set_user_info( id, "name", team1+szName )
}

}
}
What I'm trying to accomplish (I'm no scripter, I'm a script kiddie so please bear with me) is to make the plugin recognise whether you are T or CT, add Team1 for T and Team2 before your name, then at the end of your name, your actual points, so i'm trying to modify this plugin called Basic Skill Points to do exactly this for a PUG plugin, but it says Array must be indexed (variable "team1") and (variable "team2").

Thanks for taking your time to read through.


EDIT: Please help me, I did research through the documentation of the AMXX wikipedia page and I still don't have any clue what I'm doing wrong, guess I'm just dumb. I also looked at other source codes hoping that it'll shed some light upon me but it didn't unfortunately, I currently have 23 pages opened trying to research this... figured it'd be faster if someone taught me.

Last edited by deprale; 11-11-2018 at 16:26.
deprale is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 11-11-2018 , 17:40   Re: Basic array error?
Reply With Quote #2

Quote:
set_user_info( id, "name", team+szName )
Dynamic concatenation doesn't work in AMXX.

You have to format your string before.
Quote:
new szNewName[32]
formatex( szNewName, charsmax(szNewName), "%s %s", team, szName )
set_user_info( id, "name", szNewName )
__________________
My English is A0

Last edited by E1_531G; 11-11-2018 at 17:42.
E1_531G is offline
Old 11-11-2018, 20:05
deprale
This message has been deleted by deprale.
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 11-11-2018 , 20:27   Re: Basic array error?
Reply With Quote #3

SIR I THANK YOU VERY VERY MUCH, this has solved my issue hopefully.

EDIT: Now my plugin doesn't work at all.

I mean, it works, perfectly, it loads.
Except there's no change in my nickname. Not even the points.
What am I doing wrong?

https://pastebin.com/H9n7wrfD

FwdPlayerSpawn and client_infochanged(id) are key factors here

Last edited by deprale; 11-11-2018 at 21:09.
deprale is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 11-12-2018 , 11:04   Re: Basic array error?
Reply With Quote #4

About infochanged:
you need something more reliable.

Here, an example from RankSystem by OciXCrom:
PHP Code:
public client_infochanged(id)
{
    if(!
is_user_connected(id))
    {
        return
    }
        
    static const 
szKey[] = "name"
    
static szNewName[MAX_NAME_LENGTH], szOldName[MAX_NAME_LENGTH]
    
get_user_info(idszKeyszNewNamecharsmax(szNewName))
    
get_user_name(idszOldNamecharsmax(szOldName))
    
    if(!
equal(szNewNameszOldName))
    {        
        if(
g_eSettings[SAVE_TYPE] == SAVE_NICKNAME)
        {
            
use_vault(idszOldNameVAULT_WRITE)
            
use_vault(idszNewNameVAULT_READ)
            
update_hudinfo(id)
        }
        
        
set_task(DELAY_ON_CHANGE"update_vip_status"id)
    }

About spawnpost:
i think you have to add a little delay, 0.5 or 1 second. (at the round start the game applies new names for dead players, if any)
And use get_user_name() instead.
__________________
My English is A0

Last edited by E1_531G; 11-12-2018 at 11:05.
E1_531G 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 18:20.


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