Race System Does not Work????
#1

Hi everyone, i have a race system with mysql. But doenst work.

Код:
COMMAND:yarisyukle(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 2)
       	return SendClientMessage(playerid, COLOR_RED, "HATA: Bu komutu kullanmak iзin yetkiniz bulunmamaktadır!");
	if(RaceActive == 1)
		return SendClientMessage(playerid, COLOR_RED, "HATA: Zaten aktif bir yarış var, diğer yarış bitmeden bu yarışı başlamazsın!");

	new race[32];
	if(sscanf(params, "s[32]", race))
		return SendClientMessage(playerid, COLOR_YELLOW2, "Kulanım: /yarisyukle <isim>");

	format(query, sizeof(query), "SELECT * FROM `racerotation` WHERE race =  %s ", race);
	mysql_function_query(dbHandle, query, true, "OnRaceManuallyLoad", "ds", playerid, race);

	return true;
}
Код:
COMMAND:yarisbaslat(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 2)
       	return SendClientMessage(playerid, COLOR_RED, "HATA: Bu komutu kullanmak iзin yetkiniz bulunmamaktadır!");
	if(RaceActive == 0)
		return SendClientMessage(playerid, COLOR_RED, "HATA: Aktif bir yarış bulunamadı, yarış başlatmak iзin /yarisyukle yaz!");
	if(mscd <= 0)
		return SendClientMessage(playerid, COLOR_RED, "HATA: Ьzgьnьm fakat yarış zaten başladı, bu komutu kullanmanıza gerek yoktur!");	
		
	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	format(str, sizeof(str), "- AS - %s(%d) isimli yцnetici '%s' isimli yarışı başlattı!", PlayerName, playerid, RaceInfo[rName]);
	SendClientMessageToAll(COLOR_STEELBLUE, str);
	
	mscd = 0;
	mscountdown();
	return true;
}
Код:
forward RaceRotation();
public RaceRotation()
{
   	if(currPlayers == 0)
		return false;
	if(RaceActive == 1 || RaceStart == 1 || Participants > 0)
	   	return false;

	mysql_function_query(dbHandle, "SELECT * FROM `racerotation` ORDER BY rand() LIMIT 0, 1", true, "OnRaceLoad", "");
	return true;
}
Код:
stock LoadRace(temp[])
{
	format(raceName, sizeof(raceName), "%s.yr", temp);
	if(!fexist(raceName)) return false;

	format(query, sizeof(query), "SELECT * FROM `racerecords` WHERE `race_id` = %d ORDER BY  `rec_time` ASC, `time` ASC LIMIT 1;", RaceInfo[rID]);
	mysql_function_query(dbHandle, query, true, "OnRaceRecordLoad", "s", temp);

	return true;
}
Код:
forward OnRaceLoad();
public OnRaceLoad()
{
	cache_get_int(0, 0, RaceInfo[rID]);
	cache_get_row(0, 1, RaceInfo[rName]);
	cache_get_float(0, 2, RaceInfo[rFirstCP]);
	cache_get_int(0, 3, RaceInfo[rVehicle]);
	
	if(!LoadRace(RaceInfo[rName]))
		return false;

	return true;
}

forward OnRaceManuallyLoad(playerid, temp[]);
public OnRaceManuallyLoad(playerid, temp[])
{
	cache_get_int(0, 0, RaceInfo[rID]);
	cache_get_row(0, 1, RaceInfo[rName]);
	cache_get_float(0, 2, RaceInfo[rFirstCP]);
	cache_get_int(0, 3, RaceInfo[rVehicle]);

	if(!LoadRace(RaceInfo[rName]))
	{
		format(str, sizeof(str), "HATA: Ьzgьnьm fakat  %s  isimli yarış yьklenemedi!", temp);
		SendClientMessage(playerid, COLOR_RED, str);
		return true;
	}
	return true;
}
Код:
stock endrace()
{
	for(new j = 0; j < LCurrentCheckpoint; j++)
	{
	   	RaceCheckpoints[j][0] = 0.0;
	   	RaceCheckpoints[j][1] = 0.0;
	   	RaceCheckpoints[j][2] = 0.0;
	}
	
	LCurrentCheckpoint = 0;	
	
   	foreach(Player, i)
   	{
       	DisablePlayerRaceCheckpoint(i);
		
		if(RaceParticipant[i] > 0)
		{
			TextDrawHideForPlayer(i, Top5Racers);
			TextDrawHideForPlayer(i, RaceTime);
			SetVehicleVirtualWorld(GetPlayerVehicleID(i), 0);
			SetPlayerVirtualWorld(i, 0);
			TogglePlayerControllable(i, 1);
			GivePlayerSavedWeapons(i);
			SetCameraBehindPlayer(i);
			RaceParticipant[i] = 0;
			RemovePlayerMapIcon(i, 55);
		}
	}
    
	MajStart = 0;
		
	RaceActive = 0;
	IsRacing = false;
	RacersReady = 0;
	RaceStart = 0;
	Participants = 0;
	RaceInfo[rVehicle] = -1;
	RaceInfo[rFirstCP] = 0;
	
	KillTimer(MajStartTimer);
	KillTimer(timeOverTimer);
	KillTimer(noParticipants);
	
	SetTimer("RaceRotation", 300000, false);
}
Код:
ongamemodeinit under;
	SetTimer("RaceRotation", 240000, false);
mysql racerotation database:


scriptfiles .yr files:
Reply
#2

Код:
format(query, sizeof(query), "SELECT * FROM `racerotation` WHERE race =  %s ", race);
mysql_function_query(dbHandle, query, true, "OnRaceManuallyLoad", "ds", playerid, race);
Strings need apostrophes around the specifier like this '%s' but you must escape any input by the players. Use mysql_format and '%e' specifier.

In the callbacks you use cache functions, check if there are rows before using these functions. No data will result in error for invalid row indexes.
Reply
#3

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Код:
format(query, sizeof(query), "SELECT * FROM `racerotation` WHERE race =  %s ", race);
mysql_function_query(dbHandle, query, true, "OnRaceManuallyLoad", "ds", playerid, race);
Strings need apostrophes around the specifier like this '%s' but you must escape any input by the players. Use mysql_format and '%e' specifier.

In the callbacks you use cache functions, check if there are rows before using these functions. No data will result in error for invalid row indexes.
i was try but problem still have...

i dont understand why 2 race folder mysql and in scriptfiles??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)