Gang Tag System Acting Strange <Throwing Debug Errors
#1

Код:
forward GangTag_OnSetText(i);
public GangTag_OnSetText(i)
{
	new iRows,
		szResult[MAX_GANGTAGS_LEN],
		iCount,
		color,
		fontid;
	cache_get_row_count(iRows);

	while(iCount < iRows)
	{
		cache_get_value_name(iCount, "text", szResult);
		cache_get_value_name_int(iCount, "color", color);
		cache_get_value_name_int(iCount, "fontid", fontid);
		SetDynamicObjectMaterialText(arrGangTags[i][gt_iObjectID], 0, szResult, OBJECT_MATERIAL_SIZE_512x512, szFonts[fontid], 1000 / strlen(szResult), 1, GangTag_IntColor(color), 0, 1);
		++iCount;
	}
	return 1;
}
Код:
[01:12:38] [zcmd] [Eatlag]: /edittagpoint 2
[01:12:40] [debug] Run time error 11: "Divide by zero"
[01:12:40] [debug] AMX backtrace:
[01:12:40] [debug] #0 0076de18 in public GangTag_OnSetText (i=2) at ./includes/group/gangtags.pwn:213
[01:12:40] [debug] Run time error 11: "Divide by zero"
[01:12:40] [debug] AMX backtrace:
[01:12:40] [debug] #0 0076de18 in public GangTag_OnSetText (i=2) at ./includes/group/gangtags.pwn:213
[01:12:40] [debug] Run time error 11: "Divide by zero"
[01:12:40] [debug] AMX backtrace:
[01:12:40] [debug] #0 0076de18 in public GangTag_OnSetText (i=2) at ./includes/group/gangtags.pwn:213
[01:12:40] [debug] Run time error 11: "Divide by zero"
[01:12:40] [debug] AMX backtrace:
[01:12:40] [debug] #0 0076de18 in public GangTag_OnSetText (i=2) at ./includes/group/gangtags.pwn:213
[01:12:40] [debug] Run time error 11: "Divide by zero"
[01:12:40] [debug] AMX backtrace:
[01:12:40] [debug] #0 0076de18 in public GangTag_OnSetText (i=2) at ./includes/group/gangtags.pwn:213
And for some reason it spams the chat saying i edited the same point 5 times when i only did it once
Код:
[01:08:33] Usage: /edittag [ID]

[01:09:11] You have successfully edited gang tag ID 1

[01:09:11] You have successfully edited gang tag ID 1

[01:09:11] You have successfully edited gang tag ID 1

[01:09:11] You have successfully edited gang tag ID 1

[01:09:11] You have successfully edited gang tag ID 1

[01:09:52] You need a spray can to tag a wall.

[01:10:06] [Gang Tags] {DDDDDD}Spraying... Use /tag again to stop tagging.

[01:11:03] You whispered to Kelly: wtf are you doing

[01:12:22] You have successfully created a gang tag point (ID 2)

[01:12:31] Usage: /edittag [ID]

[01:12:35] You cancelled editing the gang tag.

[01:12:42] You have successfully edited gang tag ID 2

[01:12:42] You have successfully edited gang tag ID 2

[01:12:42] You have successfully edited gang tag ID 2

[01:12:42] You have successfully edited gang tag ID 2

[01:12:42] You have successfully edited gang tag ID 2

[01:15:35] You have successfully created a gang tag point (ID 3)

[01:15:46] You have successfully edited gang tag ID 3

[01:15:46] You have successfully edited gang tag ID 3

[01:15:46] You have successfully edited gang tag ID 3

[01:15:46] You have successfully edited gang tag ID 3

[01:15:46] You have successfully edited gang tag ID 3

[01:18:39] You have successfully edited gang tag ID 3

[01:18:39] You have successfully edited gang tag ID 3

[01:18:39] You have successfully edited gang tag ID 3

[01:18:39] You have successfully edited gang tag ID 3

[01:18:39] You have successfully edited gang tag ID 3

[01:19:46] (Australian accent) Eatlag says: Lol

[01:19:50] You have successfully created a gang tag point (ID 4)

[01:19:59] You have successfully edited gang tag ID 4

[01:19:59] You have successfully edited gang tag ID 4

[01:19:59] You have successfully edited gang tag ID 4

[01:19:59] You have successfully edited gang tag ID 4

[01:19:59] You have successfully edited gang tag ID 4
Reply
#2

At SetDynamicObjectMaterialText line, strlen(szResult) is 0.
`text` in db table might be empty.
Reply
#3

Код:
GangTag_Load()
{
	mysql_tquery(MainPipeline, "SELECT *FROM `gangtags` where 1", "GangTag_OnLoad", "");
}

forward GangTag_OnLoad();
public GangTag_OnLoad()
{
	new iRows;
	cache_get_row_count(iRows);
	if(!iRows) return print("[Gang Tags] There are no gang tags in the database.");
	new idx,
		szResult[MAX_GANGTAGS_LEN],
		value,
		Float:fValue;
	while(idx < iRows)
	{
		cache_get_value_name(idx, "text", szResult);
		GangTag_AdmProcess(idx, cache_get_value_name_float(idx, "x", fValue),
			cache_get_value_name_float(idx, "y", fValue),
			cache_get_value_name_float(idx, "z", fValue),
			cache_get_value_name_float(idx, "rx", fValue),
			cache_get_value_name_float(idx, "ry", fValue),
			cache_get_value_name_float(idx, "rz", fValue),
			szResult,
			cache_get_value_name_int(idx, "fontid", value),
			cache_get_value_name_int(idx, "color", value));
		idx++;
	}
	printf("[Gang Tags] Loaded %d gang tags.", idx);
	return 1;
}

GangTag_Create(iPlayerID)
{
	for(new i; i < MAX_GANGTAGS; ++i)
	{
		if(!IsValidDynamicObject(arrGangTags[i][gt_iObjectID]))
		{
			new Float:X, Float:Y, Float:Z;
			GetPlayerPos(iPlayerID, X, Y, Z);
			SetPlayerPos(iPlayerID, X + 0.5, Y + 0.5, Z + 0.5);
			mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "INSERT INTO `gangtags` (`id`, `x`, `y`, `z`, `color`) VALUES ('%d', '%f', '%f', '%f', '%d')", i, X, Y, Z, arrGroupData[PlayerInfo[iPlayerID][pMember]][g_hDutyColour]);
			return mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnCreate", "iifff", iPlayerID, i, X, Y, Z);
		}
	}
	SendClientMessage(iPlayerID, COLOR_GRAD1, "You cannot create any more gang tags.");
	return 1;
}

forward GangTag_OnCreate(iPlayerID, i, Float:X, Float:Y, Float:Z);
public GangTag_OnCreate(iPlayerID, i, Float:X, Float:Y, Float:Z)
{
	new iRows;
	cache_get_row_count(iRows);
	if(!iRows)
	{
		GangTag_AdmProcess(i, X, Y, Z, 0.0, 0.0, 0.0, "/SETUP/", 0, arrGroupData[PlayerInfo[iPlayerID][pMember]][g_hDutyColour]);
		format(szMiscArray, sizeof(szMiscArray), "You have successfully created a gang tag point (ID %d)", i);
		return SendClientMessage(iPlayerID, COLOR_YELLOW, szMiscArray);
	}
	SendClientMessage(iPlayerID, COLOR_GRAD1, "Something went wrong.");
	return 1;
}

GangTag_AdmSave(iPlayerID, i)
{
	new Float:gt_finPos[6];
	GetDynamicObjectPos(arrGangTags[i][gt_iObjectID], gt_finPos[0], gt_finPos[1],  gt_finPos[2]);
	GetDynamicObjectRot(arrGangTags[i][gt_iObjectID], gt_finPos[3], gt_finPos[4],  gt_finPos[5]);
	if(IsValidDynamic3DTextLabel(arrGangTags[i][gt_iTextID])) DestroyDynamic3DTextLabel(arrGangTags[i][gt_iTextID]);
	format(szMiscArray, sizeof(szMiscArray), "Gang Tag Point (ID %d)", i);
	arrGangTags[i][gt_iTextID] = CreateDynamic3DTextLabel(szMiscArray, COLOR_YELLOW, gt_finPos[0], gt_finPos[1],  gt_finPos[2]+2.75, 4.0);
	mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT * FROM `gangtags` WHERE `id` = '%d'", i);
	mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnSetText", "i", i);
	mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `gangtags` SET `x` = '%f', `y` = '%f', `z` = '%f', `rx` = '%f', `ry` = '%f', `rz` = '%f' WHERE `id` = '%d'",
		gt_finPos[0], gt_finPos[1],  gt_finPos[2], gt_finPos[3], gt_finPos[4],  gt_finPos[5], i);
	mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnAdmSave", "ii", iPlayerID, i);
}

forward GangTag_OnSetText(i);
public GangTag_OnSetText(i)
{
	new iRows,
		szResult[MAX_GANGTAGS_LEN],
		iCount,
		color,
		fontid;
	cache_get_row_count(iRows);

	while(iCount < iRows)
	{
		cache_get_value_name(iCount, "text", szResult);
		cache_get_value_name_int(iCount, "color", color);
		cache_get_value_name_int(iCount, "fontid", fontid);
		SetDynamicObjectMaterialText(arrGangTags[i][gt_iObjectID], 0, szResult, OBJECT_MATERIAL_SIZE_512x512, szFonts[fontid], 1000 / strlen(szResult), 1, GangTag_IntColor(color), 0, 1);
		++iCount;
	}
	return 1;
}

forward GangTag_OnAdmSave(iPlayerID, i);
public GangTag_OnAdmSave(iPlayerID, i)
{
	if(mysql_errno()) return SendClientMessage(iPlayerID, COLOR_GRAD1, "Something went wrong. Try again later.");
	format(szMiscArray, sizeof(szMiscArray), "You have successfully edited gang tag ID %d", i);
	SendClientMessage(iPlayerID, COLOR_YELLOW, szMiscArray);
	return 1;
}


GangTag_AdmProcess(i, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ, text[], fontid, color)
{
	Iter_Add(GangTags, i);
	if(IsValidDynamicObject(arrGangTags[i][gt_iObjectID])) DestroyDynamicObject(arrGangTags[i][gt_iObjectID]);
	arrGangTags[i][gt_iObjectID] = CreateDynamicObject(GANGTAGS_OBJECTID, X, Y, Z, RX, RY, RZ);
	if(IsValidDynamic3DTextLabel(arrGangTags[i][gt_iTextID])) DestroyDynamic3DTextLabel(arrGangTags[i][gt_iTextID]);
	format(szMiscArray, sizeof(szMiscArray), "Gang Tag Point (ID %d)", i);
	arrGangTags[i][gt_iTextID] = CreateDynamic3DTextLabel(szMiscArray, COLOR_YELLOW, X, Y, Z+2.75, 4.0);
	SetDynamicObjectMaterialText(arrGangTags[i][gt_iObjectID], 0, text, OBJECT_MATERIAL_SIZE_512x512, szFonts[fontid], 1000 / strlen(text), 1, GangTag_IntColor(color), 0, 1);
}
Also for some reason upon server restart the gang tags have disappeared, Their still in the database just fail to load in game
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)