15.06.2017, 20:43
(
Последний раз редактировалось GSFBart; 15.06.2017 в 21:42.
)
Eu fundi dois modos de pegar a posiзгo dos jogadores em uma corrida, porйm me deparei com um problema, que й na hora de pegar o ID do jogador
Queria saber como eu posso armazenar o ID do jogador em uma variбvel para que nгo tenha o problema de o pNome pegar o nome de todos (Foreach)
Exemplo do script do RyDeR`:
Scripts usados:
https://sampforum.blast.hk/showthread.php?tid=462892 (by knackworst)
http://forum.sa-mp.com/showpost.php?...2&postcount=44 (by RyDeR`)
PHP код:
Foreach(i, MAX_PLAYERS)
{
if(EntrouRace[i] == true)
{
new RaceIndex;
Foreach(j, MAX_PLAYERS)
{
if(EntrouRace[j] == true)
{
if(j != i)
{
if(ProgressoCP[i] < ProgressoCP[j])
{
RaceIndex++;
}
if(ProgressoCP[i] == ProgressoCP[j])
{
if(GetPlayerDistanceFromPoint(i, CoordenadasCP[ProgressoCP[i]][0], CoordenadasCP[ProgressoCP[i]][1], CoordenadasCP[ProgressoCP[i]][2]) > GetPlayerDistanceFromPoint(j, CoordenadasCP[ProgressoCP[j]][0], CoordenadasCP[ProgressoCP[j]][1], CoordenadasCP[ProgressoCP[j]][2]))
{
RaceIndex++;
}
}
}
}
}
RaceIndex = RaceIndex + 1;
new ScoreText[256] = "~n~";
for(new h; h < 5; ++h)
{
if(h < RaceIndex) format(ScoreText, sizeof(ScoreText), "%s~n~~w~~h~%d| - ~y~%s", ScoreText, h + 1, pNome(i));
else format(ScoreText, sizeof(ScoreText), "%s~n~~w~~h~%d| - ~r~~h~Ninguem", ScoreText, h + 1);
}
TextDrawSetString(TextRace[10], ScoreText);
}
}
PHP код:
if(h < RaceIndex) format(ScoreText, sizeof(ScoreText), "%s~n~~w~~h~%d| - ~y~%s", ScoreText, h + 1, pNome(i));
Exemplo do script do RyDeR`:
PHP код:
new pScoreRace[MAX_PLAYERS][Enum_Race], RaceIndex;
Foreach(i, MAX_PLAYERS)
{
if(EntrouRace[i] == true)
{
pScoreRace[RaceIndex][Race_PlayerScore] = ProgressoCP[i];
pScoreRace[RaceIndex++][Race_PlayerID] = i;
}
}
GetPlacarRace(pScoreRace, 0, RaceIndex);
new ScoreText[256] = "~n~";
for(new h; h < 5; ++h)
{
if(h < RaceIndex) format(ScoreText, sizeof(ScoreText), "%s~n~~w~~h~%d| - ~y~%s", ScoreText, h + 1, pNome(pScoreRace[h][Race_PlayerID]));
else format(ScoreText, sizeof(ScoreText), "%s~n~~w~~h~%d| - ~r~~h~Ninguem", ScoreText, h + 1);
}
TextDrawSetString(TextRace[10], ScoreText);
PHP код:
stock GetPlacarRace(array[][Enum_Race], left, right)
{
new tempLeft = left, tempRight = right, pivot = array[(left + right) / 2][Race_PlayerScore], tempVar;
while(tempLeft <= tempRight)
{
while(array[tempLeft][Race_PlayerScore] > pivot) tempLeft++;
while(array[tempRight][Race_PlayerScore] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][Race_PlayerScore], array[tempLeft][Race_PlayerScore] = array[tempRight][Race_PlayerScore], array[tempRight][Race_PlayerScore] = tempVar;
tempVar = array[tempLeft][Race_PlayerID], array[tempLeft][Race_PlayerID] = array[tempRight][Race_PlayerID], array[tempRight][Race_PlayerID] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlacarRace(array, left, tempRight);
if(tempLeft < right) GetPlacarRace(array, tempLeft, right);
}
https://sampforum.blast.hk/showthread.php?tid=462892 (by knackworst)
http://forum.sa-mp.com/showpost.php?...2&postcount=44 (by RyDeR`)