Killstreak TextDraw -
Avi Raj - 05.01.2013
Hello Guys,
i need a Textdraw in which it should show :
Player Name : Their Kill streak.
It should be Like this :
My Kill streak System:
Code:
new killstreak[MAX_PLAYERS];
//OnplayerConnect:
killstreak[playerid] = 0;
//OnPlayerDisconnect:
killstreak[playerid] = 0;
//OnPlayerDeath:
HandleKS(playerid, killerid);
stock HandleKS(playerid, killerid) //put this function outside of any callbacks or functions
{
killstreak[playerid] = 0;
killstreak[killerid] ++;
new msg1[64], msg2[64], name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name1, strlen(name1));
GetPlayerName(playerid, name2, strlen(name2));
format(msg1, strlen(msg1), "%s has ended %s's killstreak", name2, name1);
format(msg2, strlen(msg2), "%s is now on a killsreak of %i", name2, killstreak[killerid]);
SendClientMessageToAll(COLOR_CYAN, msg1);
SendClientMessageToAll(COLOR_CYAN, msg2);
switch(killstreak[killerid])
{
case 3:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 3 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 4:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 4 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 5:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 5 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 6:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 6 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 7:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 7 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 8:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 8 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 9: //change the numbers as desired and add/remove as many as you want
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 9 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
}
return 1;
}
Hope you will Help me!
Re: Killstreak TextDraw -
ThePhenix - 05.01.2013
Try it:
I think you should add a Timer to update the textdraw:
PHP Code:
new Text:killstext;
public OnGameModeInit()
{
killstext = TextDrawCreate(1.0, 5.6, " ");
TextDrawAlignment(killstext, 2);
TextDrawBackgroundColor(killstext, 255);
TextDrawFont(killstext, 3);
TextDrawLetterSize(killstext, 0.709998, 2.100001);
TextDrawColor(killstext, -1);
TextDrawSetOutline(killstext, 1);
TextDrawSetProportional(killstext, 0);
return 1;
}
stock HandleKS(playerid, killerid) //put this function outside of any callbacks or functions
{
killstreak[playerid] = 0;
killstreak[killerid] ++;
new msg1[64], msg2[64], name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], textdraw[41];
GetPlayerName(playerid, name1, strlen(name1));
GetPlayerName(playerid, name2, strlen(name2));
format(msg1, strlen(msg1), "%s has ended %s's killstreak", name2, name1);
format(msg2, strlen(msg2), "%s is now on a killsreak of %i", name2, killstreak[killerid]);
format(textdraw, sizeof(textdraw), "%s: %i", name, killstreak[killerid]);
TextDrawSetString(killstext, newtext);
TextDrawShowForAll(killstext);
SendClientMessageToAll(COLOR_CYAN, msg1);
SendClientMessageToAll(COLOR_CYAN, msg2);
switch(killstreak[killerid])
{
case 3:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 3 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 4:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 4 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 5:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 5 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 6:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 6 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 7:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 7 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 8:
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 8 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
case 9: //change the numbers as desired and add/remove as many as you want
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s is now on a Killstreak of 9 Kills.",pName);
SendClientMessageToAll(COLOR_CYAN,string);
}
}
return 1;
}
Re: Killstreak TextDraw -
Avi Raj - 05.01.2013
Error on this Line :
TextDrawSetString(killstext, newtext);
Error:
Code:
C:\DOCUME~1\User\Desktop\Server\GAMEMO~1\rvsy.pwn(469) : error 017: undefined symbol "newtext"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: Killstreak TextDraw -
ThePhenix - 05.01.2013
TextDrawSetString(killstext, textdraw);
Re: Killstreak TextDraw -
Avi Raj - 05.01.2013
No Textdraw appear in-game?
HelP!