Derby - Selecting a winner - 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: Derby - Selecting a winner (
/showthread.php?tid=638400)
Derby - Selecting a winner -
Ebisu - 31.07.2017
Hello,
So i've recently made a derby system, works perfectly with 2 players but when there are 3 players it gets messy.
Here's the problem.
If there are 3 players playing, and if one of them falls off the other two wins the round, I've been trying to find the problem but i can't, Using height check at onplayerupdate.
PHP код:
public OnPlayerUpdate(playerid)
{
if(DB_On == 1 && DB_Participants>1 && DB_Onhold == 0 && DB_Map==1)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(z < 2.1000)
{
Dcar(playerid);
DB_Member[playerid]=0;
DB_Participants--;
Slap(playerid);
SpawnPlayer(playerid);
}
}
if(DB_On == 1 && DB_Participants==1 && DB_Onhold == 0)
{
if(DB_Member[playerid]==1)
{
Dcar(playerid);
DerbyWin(playerid);
}
}
return 1;
}
Should i use a timer instead?
Re: Derby - Selecting a winner -
Ebisu - 31.07.2017
Bump
Re: Derby - Selecting a winner -
Tord - 31.07.2017
Show where you assign/sort the positions (Code)
And I would recommend a 500 ms timer, even just a 1s timers for this purpose - running only when a derby is active.
I would suggest taking a look at the following subject:
https://en.wikipedia.org/wiki/Insertion_sort
This method works perfectly. If you're working with many many items to sort, take a look at some alternatives here:
https://en.wikipedia.org/wiki/Sortin...ing_algorithms
Re: Derby - Selecting a winner -
Ebisu - 31.07.2017
Fixed.
Thanks