mysql_real_escape_string crash
#1

Hello, I have a problem with my command /accept invite [id] when a player has a invitation when he accept an error appears in server_log

Код:
[21:46:12] [debug] Run time error 4: "Array index out of bounds"
[21:46:12] [debug] AMX backtrace:
[21:46:12] [debug] #0 00252f60 in public cmd_accept (playerid=3, params[]=@0156ac90 "invite 4") at D:\gamemode\gamemodes\exgaming.pwn:37468
[21:46:12] [debug] #1 native CallLocalFunction () from samp03svr
[21:46:12] [debug] #2 0003c4d0 in public OnPlayerCommandText (playerid=3, cmdtext[]=@0156ac4c "/accept invite 4") at D:\gamemode\pawno\include\zcmd.inc:108
Код:
else if(strcmp(x_job,"invite",true) == 0)
		{
		    if(FactionOffer[playerid] != 999)
		    {
		        new str[256];
		        GetPlayerName(FactionOffer[playerid], sendername, sizeof(sendername));
		        GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
				new para1 = playerid, ftext[64];
				format(ftext, 30, "%s", NumeFactiune(PlayerInfo[FactionOffer[playerid]][pMember]));
				if(PlayerInfo[FactionOffer[playerid]][pMember] == 1) { ChosenSkin[para1] = 71; SetPlayerSkinEx(para1, 71); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 2) { ChosenSkin[para1] = 163; SetPlayerSkinEx(para1, 163); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 3) { ChosenSkin[para1] = 287; SetPlayerSkinEx(para1, 287); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 4) { ChosenSkin[para1] = 114; SetPlayerSkinEx(para1, 114); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 5) { ChosenSkin[para1] = 107; SetPlayerSkinEx(para1, 107); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 6) { ChosenSkin[para1] = 3; SetPlayerSkinEx(para1, 3); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 8) { ChosenSkin[para1] = 71; SetPlayerSkinEx(para1, 72); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 9) { ChosenSkin[para1] = 188; SetPlayerSkinEx(para1, 188); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 10) { ChosenSkin[para1] = 98; SetPlayerSkinEx(para1, 98); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 11) { ChosenSkin[para1] = 208; SetPlayerSkinEx(para1, 208); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 12) { ChosenSkin[para1] = 153; SetPlayerSkinEx(para1, 153); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 13) { ChosenSkin[para1] = 253; SetPlayerSkinEx(para1, 253); }
				else if(PlayerInfo[FactionOffer[playerid]][pMember] == 14) { ChosenSkin[para1] = 276; SetPlayerSkinEx(para1, 276); }
				else { return 1; }
                PlayerInfo[para1][pMember] = PlayerInfo[FactionOffer[playerid]][pMember];
				PlayerInfo[para1][pRank] = 1;
				PlayerInfo[para1][pModel] = ChosenSkin[para1];
				PlayerInfo[para1][pFactionJoin] = gettime();
				FactionOffer[playerid] = 999;
				SetPlayerVirtualWorld(para1,0);
				SetSpawnInfo(playerid, 0, PlayerInfo[para1][pModel],0.0,0.0,0.0,0,0,0,0,0,0,0);
				SetPlayerToTeamColor(para1);
				resetPlayerRaport(para1);
				SpawnPlayer(para1);
				mysql_format(SQL,str,sizeof(str),"UPDATE users SET `Member`='%d',`Rank`='1',`Model`='%d',`FactionJoin`='%d' WHERE `name`='%s'",PlayerInfo[para1][pMember],PlayerInfo[para1][pModel],PlayerInfo[para1][pFactionJoin],PlayerInfo[para1][pNormalName]);
				mysql_tquery(SQL,str,"","");
				new string2[256],query[256],string3[256];
				format(string,sizeof(string),"You are now a member of the %s.",ftext);
				SendClientMessage(playerid, COLOR_NICESKY, string);
				format(string,sizeof(string),"%s has joined the group (invited by %s).",giveplayer,sendername);
				SendFamilyMessage(PlayerInfo[playerid][pMember], COLOR_GENANNOUNCE, string);
				format(string2, sizeof(string2), "%s has joined the group %s (invited by %s).", PlayerInfo[playerid][pNormalName], ftext, PlayerInfo[FactionOffer[playerid]][pNormalName]); //this is line with error
				mysql_real_escape_string(string2, string3);
				mysql_format(SQL, query, sizeof(query), "INSERT INTO faction_logs (`text`, `player`,`leader`) VALUES ('%s','%d','%d')", string3, PlayerInfo[para1][pSQLID],PlayerInfo[FactionOffer[playerid]][pSQLID]);
				mysql_tquery(SQL,query,"","");
				format(string2,sizeof(string2),"%s[user:%d] has joined the group %s (invited by %s[user:%d]).",giveplayer,PlayerInfo[para1][pSQLID],ftext,sendername,PlayerInfo[FactionOffer[playerid]][pSQLID]);
				mysql_real_escape_string(string2, string3);
				Factionlog(PlayerInfo[para1][pMember],PlayerInfo[para1][pSQLID],PlayerInfo[FactionOffer[playerid]][pSQLID],string3);
				new varxx[256];
				mysql_format(SQL, varxx, sizeof(varxx), "UPDATE aplications SET `status` = '2' WHERE `name` = '%s' AND `status` = '1'",PlayerInfo[playerid][pNormalName]);
				mysql_tquery(SQL,varxx,"","");
				format(gString, sizeof(gString), "joined group %s (invited by %s[user:%i])", NumeFactiune(PlayerInfo[playerid][pMember]), sendername, PlayerInfo[FactionOffer[playerid]][pSQLID]);
				addPlayerLog(playerid, gString);

				if(PlayerInfo[playerid][pAchievements][3] == 0) {
					addToAchievements(playerid, "Be Part of a Group", 3);
				}
			}
			else return SendClientMessage(playerid, COLOR_GREY, "You don't have an active group invite request.");
		}
line error:
Код:
format(string2, sizeof(string2), "%s has joined the group %s (invited by %s).", PlayerInfo[playerid][pNormalName], ftext, PlayerInfo[FactionOffer[playerid]][pNormalName]); //this is line with error
Reply
#2

I'm sure the error is in this variable
PHP код:
PlayerInfo[FactionOffer[playerid]][pNormalName
"[ ]" parenthesis are giving problems
Reply
#3

Quote:
Originally Posted by Lucases
Посмотреть сообщение
I'm sure the error is in this variable
PHP код:
PlayerInfo[FactionOffer[playerid]][pNormalName
"[ ]" parenthesis are giving problems
And how can I solve it?
Reply
#4

What is stored in " FactionOffer[playerid] " ?
Reply
#5

Quote:
Originally Posted by Lucases
Посмотреть сообщение
What is stored in " FactionOffer[playerid] " ?
The ID of the leader that use /invite [player name / id]
Reply
#6

I found the problem, do this


pawn Код:
new LeaderID = FactionOffer[playerid];  //before the line you reset the variable
FactionOffer[playerid] = 999;
And then

pawn Код:
format(string2, sizeof(string2), "%s has joined the group %s (invited by %s).", PlayerInfo[playerid][pNormalName], ftext, PlayerInfo[LeaderID][pNormalName]);
You are resetting the variable to 999 and then trying to insert inside that format function, for that it gives you "array index out of bounds"

Try it, if the problem still persist we'll see what can we do
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)