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

[SOLVED]Array Issues


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 04-15-2013 , 01:42   [SOLVED]Array Issues
Reply With Quote #1

For somereason im getting an error on this... not 100% sure why any insight is helpful.

Accessing the array:
PHP Code:
public TargetMenuHandler(Handle:hMenuMenuAction:iActioniClientiItem)
{
    if(
iAction == MenuAction_Select)
    {
        
decl String:szMenuItem[3];
        
GetMenuItem(hMenuiItemszMenuItemsizeof(szMenuItem));
        
g_iTarget[iClient] = GetClientOfUserId(StringToInt(szMenuItem));
        
        
/* Get Target Info */
        
g_iTimeStamp[iClient] = (GetTime() -g_iTimeDifference);
        
        
GetArrayString(g_hTargetNames[iClient], g_iTarget[iClient], g_szSafeTargetNamesizeof(g_szSafeTargetName));
        
GetArrayString(g_hTargetIP[iClient], g_iTarget[iClient], g_szTargetIPsizeof(g_szTargetIP));
        
GetArrayString(g_hTargetAuthID[iClient], g_iTarget[iClient], g_szTargetAuthIDsizeof(g_szTargetAuthID));
        
        
ClearArray(g_hTargetNames[iClient]);
        
ClearArray(g_hTargetIP[iClient]);
        
ClearArray(g_hTargetAuthID[iClient]);
        
        
/* Display Main Menu */
        
DisplayMenu(g_hMainMenuiClientMENU_TIME_FOREVER);
    }

Declarations:
PHP Code:
/* Target Handlers */
new Handle:g_hTargetNames[MAXPLAYERS+1] = {INVALID_HANDLE, ...};
new 
Handle:g_hTargetIP[MAXPLAYERS+1] = {INVALID_HANDLE, ...};
new 
Handle:g_hTargetAuthID[MAXPLAYERS+1] = {INVALID_HANDLE, ...}; 
Where the receive Values:
PHP Code:
stock AddPlayersToMenu(Handle:hMenuiClient)
{
    
decl String:szName[MAX_NAME_LENGTH], String:szSafeName[MAX_NAME_LENGTH 1], String:szIP[32], String:szAuthID[32], String:szMenuItem[3];
    new 
iMenuIndex;
    
    if(
g_hTargetNames[iClient] == INVALID_HANDLE)
        
g_hTargetNames[iClient] = CreateArray(32);
        
    if(
g_hTargetIP[iClient] == INVALID_HANDLE)
        
g_hTargetIP[iClient] = CreateArray(32);
    
    if(
g_hTargetAuthID[iClient] == INVALID_HANDLE)
        
g_hTargetAuthID[iClient] = CreateArray(32);
    
    for(new 
i=1i<=MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
GetClientName(iszNamesizeof(szName));
            
ParsePlayerName(szNameszSafeNamesizeof(szSafeName));
            
GetClientIP(iszIPsizeof(szIP));
            
GetClientAuthString(iszAuthIDsizeof(szAuthID));
            
            
iMenuIndex PushArrayString(g_hTargetNames[iClient], szSafeName);
            
PushArrayString(g_hTargetIP[iClient], szIP);
            
PushArrayString(g_hTargetAuthID[iClient], szAuthID);
            
            
IntToString(iMenuIndexszMenuItemsizeof(szMenuItem))
            
            
AddMenuItem(hMenuszMenuItemszName);
        }
    }

Errors:
Code:
E:\Downloads\reporttoforum-beta.sp(769) : error 048: array (s do not match
E:\Downloads\reporttoforum-beta.sp(770) : error 048: array (s do not match
E:\Downloads\reporttoforum-beta.sp(771) : error 048: array (s do not match

Last edited by Doc-Holiday; 04-15-2013 at 03:06.
Doc-Holiday is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-15-2013 , 02:54   Re: Issue with Dynamic Array
Reply With Quote #2

What are the declarations of g_szSafeTargetName, g_szTargetIP, and g_szTargetAuthID?
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-15-2013 at 02:56.
Powerlord is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 04-15-2013 , 03:06   Re: Issue with Dynamic Array
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
What are the declarations of g_szSafeTargetName, g_szTargetIP, and g_szTargetAuthID?
PHP Code:
/* Target Variables */
new g_iTarget[MAXPLAYERS+1];
new 
String:g_szSafeTargetName[MAXPLAYERS+1][MAX_NAME_LENGTH 1];
new 
String:g_szTargetName[MAXPLAYERS+1][MAX_NAME_LENGTH];
new 
String:g_szTargetAuthID[MAXPLAYERS+1][32];
new 
String:g_szTargetIP[MAXPLAYERS+1][32];
new 
g_iTimeStamp[MAXPLAYERS+1]; 
Thanks for that lol... not really sure why i didnt check that... Fixed code below.

PHP Code:
public TargetMenuHandler(Handle:hMenuMenuAction:iActioniClientiItem)
{
    if(
iAction == MenuAction_Select)
    {
        
decl String:szMenuItem[3];
        
GetMenuItem(hMenuiItemszMenuItemsizeof(szMenuItem));
        
g_iTarget[iClient] = GetClientOfUserId(StringToInt(szMenuItem));
        
        
/* Get Target Info */
        
g_iTimeStamp[iClient] = (GetTime() -g_iTimeDifference);
        
        
GetArrayString(g_hTargetNames[iClient], g_iTarget[iClient], g_szSafeTargetName[iClient], sizeof(g_szSafeTargetName[]));
        
GetArrayString(g_hTargetIP[iClient], g_iTarget[iClient], g_szTargetIP[iClient], sizeof(g_szTargetIP[]));
        
GetArrayString(g_hTargetAuthID[iClient], g_iTarget[iClient], g_szTargetAuthID[iClient], sizeof(g_szTargetAuthID[]));
        
        
ClearArray(g_hTargetNames[iClient]);
        
ClearArray(g_hTargetIP[iClient]);
        
ClearArray(g_hTargetAuthID[iClient]);
        
        
/* Display Main Menu */
        
DisplayMenu(g_hMainMenuiClientMENU_TIME_FOREVER);
    }

Doc-Holiday is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 04-15-2013 , 03:22   Re: [SOLVED]Array Issues
Reply With Quote #4

Not sure how sm calcs array sizes but in c you could just mutiply and index providing you had the cells, i assumed it was the same.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram 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 11:07.


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