SA-MP Forums Archive
(null) - 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: (null) (/showthread.php?tid=625378)



(null) - GoldenLion - 31.12.2016

Hi, I'm working on my family system and the problem is when I want to talk in family chat then it doesn't show my rank and when I print the rank then it prints "(null)".
I have this:
Код:
new FamilyRank[MAX_FAMILIES][15][24];
and the ranks are not actually null, because for example if I create a family I'm doing this:
Код:
for (new j; j < ranks; j++) FamilyRank[i][j] = "None";
and when I print them right after doing that they are "None" so it's all good.
This is the line:
Код:
SendClientMessageEx(i, COLOR_LIGHTGREEN, "(( (%d) %s %s: %s ))", PlayerInfo[playerid][pFamilyRank], FamilyRank[familyid][PlayerInfo[playerid][pFamilyRank] - 1], GetName(playerid), params);
What's up?

EDIT: Sometimes it works though...


Re: (null) - SoLetsGO - 31.12.2016

Where did you get that SendClientMessageEx from?
Some of them only support 2 parameters.


Re: (null) - GoldenLion - 31.12.2016

Quote:
Originally Posted by SoLetsGO
Посмотреть сообщение
Where did you get that SendClientMessageEx from?
Some of them only support 2 parameters.
It has nothing to do with that.


Re: (null) - SoLetsGO - 31.12.2016

1. Could you provide the whole output please?
2. Get sure your variable "ranks" has the right value
3. Try printing all the FamilyRanks after assigning them "none":
PHP код:
for (new jranksj++) printf(FamilyRank[i][j]); 
4. Try printing the specific FamilyRank before you make the clientmessage:
PHP код:
printf(FamilyRank[familyid][PlayerInfo[playerid][pFamilyRank] - 1]); 
5. Get sure that PlayerInfo[playerid][pFamilyRank] is not lower than 1 or higher than 15.
6. Get sure that params is a one dimensional array.

PS: Printing can be a usefull tool to discover the mistake.


Re: (null) - GoldenLion - 31.12.2016

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Hi, I'm working on my family system and the problem is when I want to talk in family chat then it doesn't show my rank and when I print the rank then it prints "(null)".
I have this:
Код:
new FamilyRank[MAX_FAMILIES][15][24];
and the ranks are not actually null, because for example if I create a family I'm doing this:
Код:
for (new j; j < ranks; j++) FamilyRank[i][j] = "None";
and when I print them right after doing that they are "None" so it's all good.
This is the line:
Код:
SendClientMessageEx(i, COLOR_LIGHTGREEN, "(( (%d) %s %s: %s ))", PlayerInfo[playerid][pFamilyRank], FamilyRank[familyid][PlayerInfo[playerid][pFamilyRank] - 1], GetName(playerid), params);
What's up?
And as I said the only thing that doesn't show up is the rank so the message looks like this:
Код:
(( (1)   *name*: text... ))
the big blank there is the rank spot.


Re: (null) - SickAttack - 01.01.2017

Use strcpy (look for the macro).

Or do:
FamilyRank[i][j][0] = EOS;
strcat(FamilyRank[i][j], "None");


Re: (null) - GoldenLion - 01.01.2017

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Use strcpy (look for the macro).

Or do:
FamilyRank[i][j][0] = EOS;
strcat(FamilyRank[i][j], "None");
Yes, I have that, but
Код:
FamilyRank[i][j] = "None"
works as well.


Re: (null) - SickAttack - 01.01.2017

Does the issue persist either way?


Re: (null) - GoldenLion - 01.01.2017

Of course, because the problem is not in that. When I load the ranks from the database they get loaded properly. I printed the ranks and they were what they were supposed to be, but when I talk in family chat the ranks are still not showing up. I can print the ranks anytime and they will be good. The command is the only thing that doesn't work. I edited the post like half an hour ago saying that it worked once, but now it doesn't work again. I don't know if it'll help, but here's the whole command:
Код:
CMD:f(playerid, params[])
{
	new familyid = PlayerInfo[playerid][pFamily];
	
	if (familyid == -1)
	    return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not in a family.");
	    
	if (isnull(params))
	    return SendClientMessage(playerid, COLOR_GREY, "USAGE: /f [text]");
		
 	foreach (new i : Player) if (PlayerInfo[i][pFamily] == familyid)
 	{
		if (strlen(params) > 64)
		{
			SendClientMessageEx(i, COLOR_LIGHTGREEN, "(( (%d) %s %s: %.64s", PlayerInfo[playerid][pFamilyRank], FamilyRank[familyid][PlayerInfo[playerid][pFamilyRank] - 1], GetName(playerid), params);
			SendClientMessageEx(i, COLOR_LIGHTGREEN, "...%s ))", params[64]);
		}
		else SendClientMessageEx(i, COLOR_LIGHTGREEN, "(( (%d) %s %s: %s ))", PlayerInfo[playerid][pFamilyRank], FamilyRank[familyid][PlayerInfo[playerid][pFamilyRank] - 1], GetName(playerid), params);
	}
	return 1;
}



Re: (null) - SickAttack - 01.01.2017

To start off: foreach (new i : Player) if (PlayerInfo[i][pFamily] == familyid)

That should go inside the curly braces of the foreach line.

As 2nd point, the if-then doesn't have a minus 1, the SCM does.