Help please
#1

Errors:

Код:
C:\Users\Lachlan\Desktop\0.3a DRP\pawno\DRP.pwn(9766) : error 033: array must be indexed (variable "factionname")
C:\Users\Lachlan\Desktop\0.3a DRP\pawno\DRP.pwn(9782) : error 047: array sizes do not match, or destination array is too small
C:\Users\Lachlan\Desktop\0.3a DRP\pawno\DRP.pwn(9769) : warning 204: symbol is assigned a value that is never used: "file"
C:\Users\Lachlan\Desktop\0.3a DRP\pawno\DRP.pwn(9830) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Lachlan\Desktop\0.3a DRP\pawno\DRP.pwn(9835) : error 047: array sizes do not match, or destination array is too small
Code:

pawn Код:
if(strcmp(cmd, "/makefaction", true) == 0)
{
if(gAdminOnDuty[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GRAD2, "You must be on duty to use this command!");
return 1;
}
if (PlayerInfo[playerid][pAdmin] < 8)
{
SendClientMessage(playerid, COLOR_RED, "Invalid admin level, you cannot use this command");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_USAGE, "USAGE: /makefaction [faction name] [faction ID]");
return 1;
}
new factionname[128];
factionname = strval(tmp);
new factionid = strval(tmp);
format(string, sizeof(string), "/settings/factions.cfg", playername);
new File: file = fopen(string, io_read);
new File:hFile;
hFile = fopen(string, io_append);
new var[32];//
format(var, 32, "%s fName\n", FactionInfo[factionid][fName]);fwrite(hFile, var);
format(var, 32, "%s fLeader\n", FactionInfo[factionid][fLeader]);fwrite(hFile, var);
format(var, 32, "%d fID\n", FactionInfo[factionid][fID]);fwrite(hFile, var);
format(var, 32, "%s fRank1\n", FactionInfo[factionid][fRank1]);fwrite(hFile, var);
format(var, 32, "%s fRank2\n", FactionInfo[factionid][fRank2]);fwrite(hFile, var);
format(var, 32, "%s fRank3\n", FactionInfo[factionid][fRank3]);fwrite(hFile, var);
format(var, 32, "%s fRank4\n", FactionInfo[factionid][fRank4]);fwrite(hFile, var);
format(var, 32, "%s fRank5\n", FactionInfo[factionid][fRank5]);fwrite(hFile, var);
fclose(hFile);
FactionInfo[factionid][fName] = factionname;
return 1;
}
Reply
#2

You need to learn to script better strval = value = A NUMBER. not text...

Код:
if(strcmp(cmd, "/makefaction", true) == 0)
{
if(gAdminOnDuty[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GRAD2, "You must be on duty to use this command!");
return 1;
}
if (PlayerInfo[playerid][pAdmin] < 8)
{
SendClientMessage(playerid, COLOR_RED, "Invalid admin level, you cannot use this command");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
	idx++;
}
new offset = idx;
new result[256];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
	result[idx - offset] = cmdtext[idx];
	idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
	SendClientMessage(playerid, COLOR_WHITE, "[ ! ] USAGE: /makefaction (Faction name) (Faction ID)");
	return 1;
}
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
	SendClientMessage(playerid,COLOR_WHITE, "[ ! ] USAGE: /makefaction (Faction name) (Faction ID)");
	return 1;
}
new factionid = strval(tmp);
format(string, sizeof(string), "/settings/factions.cfg", playername);
new File: file = fopen(string, io_read);
new File:hFile;
hFile = fopen(string, io_append);
new var[32];//
format(var, 32, "%s fName\n",result);fwrite(hFile,var);
format(var, 32, "%s fLeader\n", FactionInfo[factionid][fLeader]);fwrite(hFile, var);
format(var, 32, "%d fID\n", FactionInfo[factionid][fID]);fwrite(hFile, var);
format(var, 32, "%s fRank1\n", FactionInfo[factionid][fRank1]);fwrite(hFile, var);
format(var, 32, "%s fRank2\n", FactionInfo[factionid][fRank2]);fwrite(hFile, var);
format(var, 32, "%s fRank3\n", FactionInfo[factionid][fRank3]);fwrite(hFile, var);
format(var, 32, "%s fRank4\n", FactionInfo[factionid][fRank4]);fwrite(hFile, var);
format(var, 32, "%s fRank5\n", FactionInfo[factionid][fRank5]);fwrite(hFile, var);
fclose(hFile);
return 1;
}
Reply
#3

I know I do, thanks for the help
Reply
#4

Sorry for double, but this will always send the "USAGE: /makefaction...." message ingame, it wont work ;(
Reply
#5

Код:
if(strcmp(cmd, "/makefaction", true) == 0)
{
if(gAdminOnDuty[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GRAD2, "You must be on duty to use this command!");
return 1;
}
if (PlayerInfo[playerid][pAdmin] < 8)
{
SendClientMessage(playerid, COLOR_RED, "Invalid admin level, you cannot use this command");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
	idx++;
}
new offset = idx;
new result[256];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
	result[idx - offset] = cmdtext[idx];
	idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
	SendClientMessage(playerid, COLOR_WHITE, "[ ! ] USAGE: /makefaction (Faction name) (Faction ID)");
	return 1;
}
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "[ ! ] USAGE: /makefaction (Faction name) (Faction ID)");
new factionid;
factionid = strval(tmp);
format(string, sizeof(string), "/settings/factions.cfg", playername);
new File: file = fopen(string, io_read);
new File:hFile;
hFile = fopen(string, io_append);
new var[32];//
format(var, 32, "%s fName\n",result);fwrite(hFile,var);
format(var, 32, "%s fLeader\n", FactionInfo[factionid][fLeader]);fwrite(hFile, var);
format(var, 32, "%d fID\n", FactionInfo[factionid][fID]);fwrite(hFile, var);
format(var, 32, "%s fRank1\n", FactionInfo[factionid][fRank1]);fwrite(hFile, var);
format(var, 32, "%s fRank2\n", FactionInfo[factionid][fRank2]);fwrite(hFile, var);
format(var, 32, "%s fRank3\n", FactionInfo[factionid][fRank3]);fwrite(hFile, var);
format(var, 32, "%s fRank4\n", FactionInfo[factionid][fRank4]);fwrite(hFile, var);
format(var, 32, "%s fRank5\n", FactionInfo[factionid][fRank5]);fwrite(hFile, var);
fclose(hFile);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)