22.10.2014, 11:08
Here is the code which is ending the derbies (don't mind the debug msg's)
This is how it looks at the moment when there is only one player left (the other players leave by commands or exiting vehicles)
And this is when there are multiple people getting called up on the "endmonsterderby" callback. This is ofc when the derby ends and the scores are counted for 120 seconds in the derby.
Here is two players in endmonsterderby. (old pic, no debug msgs)
This makes no sense to me at all, since i used
in the code, and afterwards checking if the slots are taken or not.
What is my problem here, and how can i fix it ?
pawn Код:
public EndMonsterDerby()
{
//if(!MonsterDerby) return 1;
if(players == 0) return 1;
IRC_GroupSay(gGroupID, IRC_CHANNEL,"4<-- 10The derby has ended!4 -->");
new Hscore = -999999, Slot1 = -1, Slot2 = -1, Slot3 = -1, Slot4 = -1;
new str[120];
SendClientMessageToAll(-1,"------------------------------------------------------------------------------------");
//IRC_GroupSay(gGroupID, IRC_CHANNEL,"4<-- 1---------------------------------------------------------------------------4 -->");
SendClientMessageToAll(0x33FF33AA,"The Monster Derby has Ended!");
foreach(new i:Player)
{
if(GetPVarInt(i,"InMonsterDerby"))
{
if(DerbyScore[i] > Hscore)
{
if(IsPlayerConnected(GetPlayerID("denNorske")))
SendClientMessage(GetPlayerID("denNorske"), -1,""corange"Debug: "cwhite"Derby winner called on "corange"EndMonsterDerby");
Slot1 = i;
Hscore = DerbyScore[i];
new falls;
if(Hscore == 0)
falls = 0;
else
falls=(Hscore/ 10 *-1);
format(str,sizeof(str), ""cgreen"5Winner:1 %s 5(ID:1 %d5) - Number of falls: 1 %d",PlayerName(i),i, falls);
IRC_GroupSay(gGroupID, IRC_CHANNEL,str);
format(str,sizeof(str), ""cgreen"Winner:"cwhite" %s (ID:%d)"cgreen" - Number of falls:"cwhite" %d",PlayerName(i),i, falls);
SendClientMessageToAll(0x33FF33AA,str);
SetPlayerScore(i,GetPlayerScore(i)+10);
AccInfo[i][cookies]=AccInfo[i][cookies] + 5;
GivePlayerMoney(i, 5000);
}
}
}
Hscore = -999999;
foreach(new i:Player)
{
if(GetPVarInt(i,"InMonsterDerby") && i != Slot1)
{
if(DerbyScore[i] > Hscore)
{
if(IsPlayerConnected(GetPlayerID("denNorske")))
SendClientMessage(GetPlayerID("denNorske"), -1,""corange"Debug: "cwhite"Derby 2. place called on "corange"EndMonsterDerby");
Slot2 = i;
Hscore = DerbyScore[i];
new falls;
falls=(Hscore/ 10 * -1);
format(str,sizeof(str), ""cgreen"5Second Place:1 %s 5(ID:1 %d5) - Number of falls: 1 %d",PlayerName(i),i, falls);
IRC_GroupSay(gGroupID, IRC_CHANNEL,str);
format(str,sizeof(str), ""cyellow"Second Place:"cwhite" %s (ID:%d)"cyellow" - Number of falls:"cwhite" %d",PlayerName(i),i, falls);
SendClientMessageToAll(0x33FF33AA,str);
SetPlayerScore(i,GetPlayerScore(i)+5);
AccInfo[i][cookies]=AccInfo[i][cookies] + 3;
GivePlayerMoney(i, 2500);
}
}
}
Hscore = -999999;
foreach(new i:Player)
{
if(GetPVarInt(i,"InMonsterDerby") && i != Slot1 && i != Slot2)
{
if(DerbyScore[i] > Hscore)
{
Slot3 = i;
Hscore = DerbyScore[i];
new falls;
falls=(Hscore/ 10 * -1);
format(str,sizeof(str), ""cgreen"5Third Place:1 %s 5(ID:1 %d5) - Number of falls: 1 %d",PlayerName(i),i, falls);
IRC_GroupSay(gGroupID, IRC_CHANNEL,str);
format(str,sizeof(str), ""corange"Third Place:"cwhite" %s (ID:%d)"corange" - Number of falls:"cwhite" %d",PlayerName(i),i, falls);
SendClientMessageToAll(0x33FF33AA,str);
SetPlayerScore(i,GetPlayerScore(i)+1);
AccInfo[i][cookies]=AccInfo[i][cookies] + 1;
GivePlayerMoney(i, 500);
}
}
}
Hscore = -999999;
foreach(new i:Player)
{
if(GetPVarInt(i,"InMonsterDerby") && i != Slot1 && i != Slot2 && i != Slot3)
{
if(DerbyScore[i] > Hscore)
{
Slot4 = i;
Hscore = DerbyScore[i];
new falls;
falls=(Hscore/ 10 * -1);
format(str,sizeof(str), ""cgreen"5Fourth Place:1 %s 5(ID:1 %d5) - Number of falls: 1 %d",PlayerName(i),i, falls);
IRC_GroupSay(gGroupID, IRC_CHANNEL,str);
format(str,sizeof(str), ""cblue"Fourth Place:"cwhite" %s (ID:%d)"cblue" - Number of falls:"cwhite" %d",PlayerName(i),i, falls);
SendClientMessageToAll(0x33FF33AA,str);
}
}
}
Hscore = -999999;
foreach(new i:Player)
{
if(GetPVarInt(i,"InMonsterDerby") && i != Slot1 && i != Slot2 && i != Slot3 && i != Slot4)
{
if(DerbyScore[i] > Hscore)
{
Hscore = DerbyScore[i];
new falls;
falls=(Hscore/ 10 * -1);
format(str,sizeof(str), ""cgreen"5Fifth Place:1 %s 5(ID:1 %d5) - Number of falls: 1 %d",PlayerName(i),i, falls);
IRC_GroupSay(gGroupID, IRC_CHANNEL,str);
format(str,sizeof(str), ""cred"Fifth Place:"cwhite" %s (ID:%d)"cred" - Number of falls:"cwhite" %d",PlayerName(i),i, falls);
SendClientMessageToAll(0x33FF33AA,str);
}
}
}
SendClientMessageToAll(-1,"------------------------------------------------------------------------------------");
//IRC_GroupSay(gGroupID, IRC_CHANNEL,"4<-- 1---------------------------------------------------------------------------4 -->");
if(Slot1 != -1)
SendClientMessage(Slot1, blue, "Information: "cwhite"You won 5 cookies, 10 score and 5000$!");
if(Slot2 != -1)
SendClientMessage(Slot2, blue, "Information: "cwhite"You earned 3 cookies, 5 score and 2500$!");
if(Slot3 != -1)
SendClientMessage(Slot3, blue, "Information: "cwhite"You earned 1 cookie, 1 score and 500$");
foreach(new i:Player)
{
if(GetPVarInt(i,"InMonsterDerby"))
{
DerbyScore[i]=0;
SetPVarInt(i,"InMonsterDerby",0);
if(GetPVarInt(i, "wasgodon") == 0)
{
SetPVarInt(i, "GOD", 0);
SetPVarInt(i, "wasgodon", 0);
}
DestroyVehicle(GetPVarInt(i,"MonsterID")) && SetPVarInt(i, "MonsterID", -1);
SetPlayerPos(i,GetPVarFloat(i,"Xpos"),GetPVarFloat(i,"Ypos"),GetPVarFloat(i,"Zpos"));
SetPlayerInterior(i, 0);
SetPlayerVirtualWorld(i, 0);
}
}
players = 0;
SetTimer("StartMonsterDerby",TimeBetweenDerby*1000,0);
new namez = GetPlayerID("denNorske");
if(IsPlayerConnected(namez))
SendClientMessage(namez, -1, "DEBUG: StartMonsterDerby TIMER started on EndMonsterDerby ( Winners announced)");
MonsterDerby = 0;
KillTimer(scorecheck);
DerbyOpen = 0;
return 1;
}
And this is when there are multiple people getting called up on the "endmonsterderby" callback. This is ofc when the derby ends and the scores are counted for 120 seconds in the derby.
Here is two players in endmonsterderby. (old pic, no debug msgs)
This makes no sense to me at all, since i used
pawn Код:
Slot1/2/3/4 = i;
What is my problem here, and how can i fix it ?