Help with TextDraw - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with TextDraw (
/showthread.php?tid=267794)
Help with TextDraw -
Sreadon - 09.07.2011
Hello guys, I need help to make a textdraw who will showing something like this : "RED: X - BLUE: Y"
I have read a lot of threads about this, but I can't understand all.. so I post here.
Here my code:
PHP код:
#define Teamblue 1
#define Teamred 2
new team1score;
new team2score;
public OnPlayerSpawn(playerid)
{
switch(pClass[playerid])
{
case 0:
{
SetPlayerColor(playerid, 0x33CCFFAA); // Blue
SetPlayerTeam(playerid, 1); // I've do that for making player in the team 1
}
case 1:
{
SetPlayerColor(playerid, 0xFF0000AA); // Red
SetPlayerTeam(playerid, 2); // I've do that for making player in the team 2
}
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
if(GetPlayerTeam(killerid) == 1)
{
team1score++; //Sets team1score
}
if(GetPlayerTeam(killerid) == 2)
{
team2score++; //Sets team2score
}
if(team1score == 100 || team2score == 100)
{
SendRconCommand("gmx"); //Restarts Server
}
return 1;
}
As can you see, the fonction who ad score to the team is here, but I really don't know what I need to do with textdraw, and I think I will need de timer, right?
Can I make something like this?:
PHP код:
public OnPlayerConnect(playerid)
{
new newtext[41];
GetPlayerScore(playerid, team1score);
format(newtext, sizeof(newtext), "BLUE: %d", team1score);
TextDrawSetString(textdrawblue, newtext);
TextDrawShowForPlayer(playerid, textdrawblue);
return 1;
}
I didn't ask you to make it for me, but can you help me ? I really need this, I've done others things and this really stop me..
Thank's for your help, and sorry for my english, but I'm not English
Re: Help with TextDraw -
[HiC]TheKiller - 09.07.2011
You're on the right track but instead of updating the string on OnPlayerConnect, update it on OnPlayerDeath.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
if(GetPlayerTeam(killerid) == 1)
{
team1score++; //Sets team1score
new newtext[41];
GetPlayerScore(playerid, team1score);
format(newtext, sizeof(newtext), "BLUE: %d", team1score);
TextDrawSetString(textdrawblue, newtext);
}
if(GetPlayerTeam(killerid) == 2)
{
team2score++; //Sets team2score
new newtext[41];
format(newtext, sizeof(newtext), "Red: %d", team2score);
TextDrawSetString(textdrawred, newtext);
}
if(team1score == 100 || team2score == 100)
{
SendRconCommand("gmx"); //Restarts Server
}
return 1;
}
Re : Help with TextDraw -
Sreadon - 09.07.2011
Thank's for your help man

I've test it, and it's update perfectly. I'll try to ad a background to this now.