23.07.2015, 21:32
o/ guys,
So I am working onn this script and it's based on rounds where you kill anyone you can (DM).
I've been trying to get this to work properly but it seems like it's not willing to cooperate with me.
Here's the code bit:
(btw I don't get any errors when compilaing/running.)
The issue is once a new HighestKiller comes up, the new TEXTDRAW gets layed over the old one and you can't read much. and I tried using TextDrawDestroy but I can't do it.
I was wondering if there is a way to detect when highestkillerid changes in order to destroy the old textdraw and create the new textdraw.
If anyone could help me that'd be great!
Thank you =)
So I am working onn this script and it's based on rounds where you kill anyone you can (DM).
I've been trying to get this to work properly but it seems like it's not willing to cooperate with me.
Here's the code bit:
(btw I don't get any errors when compilaing/running.)
Код:
public OnPlayerDeath(playerid, killerid, reason) { if(killerid == playerid) { new message[256]; GetPlayerName(playerid, playername, sizeof(playername)); SendDeathMessage(killerid, playerid, reason); format(message, sizeof(message), ">> %s has killed himself.", playername); SendClientMessageToAll(SYSTEM_COLOR, message); } if(killerid != INVALID_PLAYER_ID || killerid != playerid) { new rand = random(sizeof(SoundOnDeath)), Float:Xp, Float:Yp, Float:Zp, Float:Xk, Float:Yk, Float:Zk; GetPlayerPos(playerid, Xp, Yp, Zp); GetPlayerPos(killerid, Xk, Yk, Zk); PlayerPlaySound(killerid, SoundOnDeath[rand][0],Xk,Yk,Zk); SendDeathMessage(killerid, playerid, reason); SetPVarInt(playerid, "PKills", PlayerInfo[killerid][pKills]++); SetPVarInt(playerid, "PDeaths", PlayerInfo[playerid][pDeaths]++); roundstats[playerid][rKills]++; roundstats[playerid][rDeaths]++; SetPlayerHealth(killerid, 100); SetPlayerArmour(killerid, 100); } return 1; }
Код:
enum rInfo { rKills, rDeaths } new roundstats[MAX_PLAYERS][rInfo]; stock GetHighestKiller() // TOP KILLER. { new kills; new player = -1; for (new i=0, mx = GetMaxPlayers(); i!=mx; ++i) { if(IsPlayerConnected(i)) { if (roundstats[i][rKills] > kills) { player = i; kills = roundstats[i][rKills]; } } } return player; }
Код:
public OnPlayerSpawn(playerid) { new Text:messagetextdraw; new topkillermessage[256]; messagetextdraw = TextDrawCreate(1.0, 5.6, ""); new highestkillerid = GetHighestKiller(); GetPlayerName(highestkillerid, playername, sizeof(playername)); format(topkillermessage, sizeof(topkillermessage), "%s has the most amount of kills.", playername); TextDrawSetString(messagetextdraw,topkillermessage); TextDrawShowForPlayer(playerid, messagetextdraw); }
I was wondering if there is a way to detect when highestkillerid changes in order to destroy the old textdraw and create the new textdraw.
If anyone could help me that'd be great!
Thank you =)