Problems with getting correct id/name -
SaW_[VrTx] - 13.05.2011
Hello..
I'm making Destruction Derby GM and i'm experiencing some problems.. I can't figure out how to get winner id under OnPlayerDeath.
Here's the script:
http://pastebin.com/V7K76pkt
First bug: It gives points (PlayerInfo[i][points]) to everyone
Second bug: Winner is always with highest id (last id in score tab).
pawn Код:
if(GetAliveDrivingPlayers()==1)
{
new name2[MAX_PLAYER_NAME];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(PlayerInfo[i][dead]==0 || beidzies==0)
{
PlayerInfo[i][points]+=3;
GetPlayerName(i, name2, sizeof(name2));
}
}
atskaite=10;
format(string,sizeof(string),"Uzvarētājs: {00F7FF}%s",name2);
SendClientMessageToAll(COLOR_LGREEN,"*******Raunds beidzies*******");
SendClientMessageToAll(COLOR_LGREEN,string);
SendClientMessageToAll(COLOR_LGREEN,"Jauns raunds sāksies pēc 10 sekundēm!");
SendClientMessageToAll(COLOR_LGREEN,"*******Raunds beidzies*******");
beidzies=1;
beidzies = round ended
atskaite = timer to new round
Is this a samp bug, or did i really made mistake somewhere?
GetAliveDrivingPlayers();
pawn Код:
forward GetAliveDrivingPlayers();
public GetAliveDrivingPlayers()
{
new pl,Float:hp;
for(new i=0;i<MAX_PLAYERS;i++)
{
GetPlayerHealth(i,hp);
if(IsPlayerConnected(i)&&IsPlayerNPC(i)==0&&IsPlayerInAnyVehicle(i)&&hp>0) pl++;
}
return pl;
}
AW: Problems with getting correct id/name -
Nero_3D - 13.05.2011
We only need the last guy so I put the code from the function in OnPlayerDeath
pawn Код:
//OnPlayerDeath
new
i,
Float: health,
last = INVALID_PLAYER_ID;
for( ; i != MAX_PLAYERS; ++i) {
if(GetPlayerHealth(i, health) && !IsPlayerNPC(i) && IsPlayerInAnyVehicle(i) && health) {
if(last != INVALID_PLAYER_ID) {
last = INVALID_PLAYER_ID;
break;
}
last = i;
}
}
if(last != INVALID_PLAYER_ID) {
new
tmp[20 + MAX_PLAYER_NAME] = "Uzvarētājs: {00F7FF}";
PlayerInfo[last][points] += 3;
GetPlayerName(last, tmp[20], MAX_PLAYER_NAME);
SendClientMessageToAll(COLOR_LGREEN,"*******Raunds beidzies*******");
SendClientMessageToAll(COLOR_LGREEN, tmp);
SendClientMessageToAll(COLOR_LGREEN,"Jauns raunds sāksies pēc 10 sekundēm!");
SendClientMessageToAll(COLOR_LGREEN,"*******Raunds beidzies*******");
atskaite=10;
beidzies=1;
}
I dont know why you need beidzies
But if you use it as a flag (0 / 1) I recommand to tag it as boolean (false / true)
Normal variables use 4 bytes (32 bits) a boolean 1 bit (in theory)
Re: Problems with getting correct id/name -
SaW_[VrTx] - 13.05.2011
last = INVALID_PLAYER_ID;
...
if(last != INVALID_PLAYER_ID) {
last = INVALID_PLAYER_ID; }
How is this going to work? But anyway, i will test it. And you can't just make new i; (i think).. it will be 0. So it will check ID 0 only..
edit: not working.. Doesn't show winner (doesn't metter which id wins).
Re: Problems with getting correct id/name -
SaW_[VrTx] - 14.05.2011
bump
AW: Problems with getting correct id/name -
Nero_3D - 14.05.2011
I tested it and it does what I scripted it to do, it gives the last alive player who is in a vehicle and not an NPC
But I dont know what you understand under "the winner"
Re: AW: Problems with getting correct id/name -
SaW_[VrTx] - 15.05.2011
Quote:
Originally Posted by Nero_3D
I tested it and it does what I scripted it to do, it gives the last alive player who is in a vehicle and not an NPC
But I dont know what you understand under "the winner"
|
Winner is the only one player who is still in car.