Need some help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need some help (
/showthread.php?tid=304932)
Need some help -
Cowboy - 20.12.2011
Hello,
I am trying to make when a player creates a gang, and the player's gangname is already choosen by someone else, it should send a message, but it ain't working.
Here's the code
pawn Код:
for(new i; i < TotalGangs; i++)
{
format(CheckName, sizeof(CheckName), Gang_File, i);
if(DOF_FileExists(CheckName))
{
new gname[128];
strcat(gname, DOF_GetString(CheckName, "Name"), 128);
if(strcmp(GangName, gname, true) == 0)
{
SendClientMessage(playerid, Red, "A gang with this name already exists");
return 1;
}
}
}
It just keeps on making the gang, please help, thanks.
Rep will be given.
Re: Need some help -
Cowboy - 21.12.2011
Bump.
Re: Need some help -
Ash. - 21.12.2011
Ignore me...
Give me a second.
Re: Need some help -
Cowboy - 21.12.2011
Quote:
Originally Posted by funky1234
Ignore me...
Give me a second.
|
Hey, could you figure it out?
Re: Need some help -
Ash. - 21.12.2011
Are you sure the original file exists. (The 'CheckName' file?)
Re: Need some help -
Cowboy - 22.12.2011
Yes, it does exists
pawn Код:
// This is my define for Gang_File
#define Gang_File "Gangs/%d.ini"
new TotalGangs;
public OnGameModeInit()
{
if(!DOF_FileExists(CFG_File))
{
DOF_CreateFile(CFG_File);
DOF_SetInt(CFG_File, "Gangs", 0);
print("CFG File created");
}
else
{
TotalGangs = DOF_GetInt(CFG_File, "Gangs");
for(new i = 0; i <= TotalGangs; i++)
{
GangInfo[i][Gangs] = i;
}
printf("CFG File loaded. %d gangs loaded", TotalGangs);
}
DOF_SaveFile();
return 1;
}
There's the TotalGangs variable which also works, so yeah, maybe something wrong with the code I provided in the first post?
Re: Need some help -
Cowboy - 22.12.2011
I had another attempt but failed, I don't know what I have done wrong. Maybe with the strcmp or strcat line?
Re: Need some help -
skaTim - 22.12.2011
Код:
for(new i; i < TotalGangs; i++)
{
format(CheckName, sizeof(CheckName), Gang_File, i);
if(DOF_FileExists(CheckName))
{
new gname[128];
strcat(gname, DOF_GetString(CheckName, "Name"), 128);
if(!strcmp(GangName, gname, true) == 0)
{
SendClientMessage(playerid, Red, "A gang with this name already exists");
return 1;
}
}
}
Re: Need some help -
Cowboy - 22.12.2011
It gave me a tag mismatch warning, how can I fix it?
Re: Need some help -
Ash. - 22.12.2011
Quote:
Originally Posted by Cowboy
It gave me a tag mismatch warning, how can I fix it?
|
The user that posted above you, has placed an exclamation mark infront of the strcmp function. This has actually broken your code.
Doing !strcmp(...) is the same as doing strcmp(...) == 0, hence there is no difference.
The reason you are getting the warning is because you're doing two checks (checking with an exclamation mark and the == 0 method.
I'm unsure on your issue, though.