Company Filesaving problem. [REP+] -
Chriham3 - 25.10.2011
Hello. I am trying to create a company system for my server but I get this error message:
Код:
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(110) : warning 219: local variable "Companies" shadows a variable at a preceding level
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(112) : warning 219: local variable "Companies" shadows a variable at a preceding level
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(113) : warning 213: tag mismatch
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(112) : warning 204: symbol is assigned a value that is never used: "Companies"
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(110) : warning 203: symbol is never used: "Companies"
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(129) : warning 213: tag mismatch
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(131) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(132) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(133) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(134) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(135) : error 032: array index out of bounds (variable "CompanyInfo")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
The way I scripted is was:
pawn Код:
#define COMPANYPATH "/Companies/%s.ini"
pawn Код:
enum Companies
{
Company1,
Company2,
Company3,
Company4,
Company5,
Company6,
Company7,
Company8,
Company9,
Company10,
Company11,
Company12,
Company13,
Company14,
Company15
}
pawn Код:
new CompanyInfo[Companies][cInfo];
pawn Код:
stock CompanyPath(Companies)
{
new string[128],Companies[15];
format(string,sizeof(string),COMPANYPATH,Companies);
return string;
}
pawn Код:
public OnGameModeInit()
{
new INI:File = INI_Open(CompanyPath(Companies));
INI_SetTag(File,"data");
INI_WriteInt(File,"Company ID",CompanyInfo[Companies][cID]);
INI_WriteInt(File,"Company Name",CompanyInfo[Companies][cName]);
INI_WriteInt(File,"Company Bank",CompanyInfo[Companies][cCash]);
INI_WriteInt(File,"Company Payrate",CompanyInfo[Companies][cPayrate]);
INI_WriteInt(File,"Company Owner",CompanyInfo[Companies][cOwner]);
INI_Close(File);
SetGameModeText("Remaking server");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
I am not so good in scripting when it comes to file-reading and saving, so I'd really appreciate some help, and I'll give rep+ for someone who helps.
Re: Company Filesaving problem. [REP+] -
SchurmanCQC - 25.10.2011
pawn Код:
stock CompanyPath(Companies1)
{
new string[128],Companies1[15];
format(string,sizeof(string),COMPANYPATH,Companies);
return string;
}
I just fixed the shadowing variable problem.
pawn Код:
enum Companies
{
Company1,
Company2,
Company3,
Company4,
Company5,
Company6,
Company7,
Company8,
Company9,
Company10,
Company11,
Company12,
Company13,
Company14,
Company15
};
Pointed out two problems that could be the source of these
Re: Company Filesaving problem. [REP+] -
Chriham3 - 25.10.2011
Now I got:
Код:
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(113) : warning 219: local variable "Companies1" shadows a variable at a preceding level
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(114) : warning 213: tag mismatch
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(113) : warning 204: symbol is assigned a value that is never used: "Companies1"
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(111) : warning 203: symbol is never used: "Companies1"
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(130) : warning 213: tag mismatch
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(132) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(133) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(134) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(135) : error 032: array index out of bounds (variable "CompanyInfo")
C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(136) : error 032: array index out of bounds (variable "CompanyInfo")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
Re: Company Filesaving problem. [REP+] -
Chriham3 - 27.10.2011
bump
Re: Company Filesaving problem. [REP+] -
Kingunit - 27.10.2011
Lines?
Re: Company Filesaving problem. [REP+] -
jonrb - 27.10.2011
This probably won't fix any of your previous errors but as far as I know you need to remove the first '/'
Код:
#define COMPANYPATH "/Companies/%s.ini"
In your fix here:
Код:
stock CompanyPath(Companies1)
{
new string[128],Companies1[15];
format(string,sizeof(string),COMPANYPATH,Companies);
return string;
}
You have a few problems. Firstly, you are taking "Companies1" as a parameter. Why are you then defining "Companies1" as a new string? Secondly, I think in your format you'll be wanting to take the parameter "Companies1" rather than the enum "Companies". It might help you to re-name some of your variables. Consider changing it to "company_id" or something, so that you don't get confused.
For the "Array index out of bounds" error, I need to see your "new CompanyInfo[..." line. At a guess, I'd say you've done "new CompanyInfo[Companies]" instead of "new CompanyInfo[MAX_COMPANIES][Companies]", where "MAX_COMPANIES" would be the total number of companies that your script allows.
Re: Company Filesaving problem. [REP+] -
Chriham3 - 27.10.2011
I can't seem to fix it. I will study some more of Y_INI and try to fix it then.