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

Simple Error help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NC.svtrade
Senior Member
Join Date: Nov 2015
Old 02-23-2017 , 01:05   Simple Error help
Reply With Quote #1

PHP Code:
new String:partyname[MAXPLAYERS+1][256];

stock TF2DayZ_GetPartyInfo(clientString:info[][]) {
    new 
ptyy TF2DayZ_WhereIsClientPartyf(client);
    if(
ptyy != -1) {
        
strcopy(info[0], sizeof(info[0]), partyname[ptyy]); // Line 306
        
new 0;
        for(new 
i=1i<=7i++) {
            if(
party[ptyy][i-1] != 0) {
                new 
String:name[256];
                
GetClientName(party[ptyy][i-1], name256);
                
strcopy(info[i], sizeof(info[i]), name);
                
j+=1;
            }
        }
        return 
j;
    }
    return -
1;

Error
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// TDZMod.sp
//
// dayz/cparty.sp(306) : error 001: expected token: "]", but found "-integer value-"
// dayz/cparty.sp(306) : warning 215: expression has no effect
// dayz/cparty.sp(306) : error 001: expected token: ";", but found "]"
// dayz/cparty.sp(306) : error 029: invalid expression, assumed zero
// dayz/cparty.sp(306) : fatal error 190: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
//
// Compilation Time: 0.97 sec
// ----------------------------------------

Press enter to exit ...

I am making party system, but there is one error that i can't solve.

How to fix it?
NC.svtrade is offline
clug
Junior Member
Join Date: May 2016
Location: Australia
Old 02-23-2017 , 01:39   Re: Simple Error help
Reply With Quote #2

When using sizeof on an array of strings, you don't need to specify an index, just that it is an array.
e.g. sizeof(info[i]) won't work, but sizeof(info[]) will.
Also, you are using old-style declarations. Not that it's a problem, but I'd recommend changing to the new style if possible.

Here's (probably) fixed code, could be other problems:
PHP Code:
new String:partyname[MAXPLAYERS+1][256]; 

stock TF2DayZ_GetPartyInfo(clientString:info[][]) { 
    new 
ptyy TF2DayZ_WhereIsClientPartyf(client); 
    if(
ptyy != -1) { 
        
strcopy(info[0], sizeof(info[]), partyname[ptyy]); // Line 306 
        
new 0
        for(new 
i=1i<=7i++) { 
            if(
party[ptyy][i-1] != 0) { 
                new 
String:name[256]; 
                
GetClientName(party[ptyy][i-1], name256); 
                
strcopy(info[i], sizeof(info[]), name); 
                
j+=1
            } 
        } 
        return 
j
    } 
    return -
1


Last edited by clug; 02-23-2017 at 01:40.
clug is offline
NC.svtrade
Senior Member
Join Date: Nov 2015
Old 02-23-2017 , 05:52   Re: Simple Error help
Reply With Quote #3

Quote:
Originally Posted by clug View Post
When using sizeof on an array of strings, you don't need to specify an index, just that it is an array.
e.g. sizeof(info[i]) won't work, but sizeof(info[]) will.
Also, you are using old-style declarations. Not that it's a problem, but I'd recommend changing to the new style if possible.

Here's (probably) fixed code, could be other problems:
PHP Code:
new String:partyname[MAXPLAYERS+1][256]; 

stock TF2DayZ_GetPartyInfo(clientString:info[][]) { 
    new 
ptyy TF2DayZ_WhereIsClientPartyf(client); 
    if(
ptyy != -1) { 
        
strcopy(info[0], sizeof(info[]), partyname[ptyy]); // Line 306 
        
new 0
        for(new 
i=1i<=7i++) { 
            if(
party[ptyy][i-1] != 0) { 
                new 
String:name[256]; 
                
GetClientName(party[ptyy][i-1], name256); 
                
strcopy(info[i], sizeof(info[]), name); 
                
j+=1
            } 
        } 
        return 
j
    } 
    return -
1

Thanks for replying fast!

And I think I will change all my old-style declarations

Thanks
NC.svtrade is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 02-23-2017 , 06:41   Re: Simple Error help
Reply With Quote #4

You're still not going to be able to do sizeof(info[]) because you didn't declare a size for it in the parameter list. Your choices for that are to set a fixed size or pass sizes (or, I guess, just assume sizes).
Fyren 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:08.


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