Help with TextDraw
#1

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(playerid0x33CCFFAA); // Blue
            
SetPlayerTeam(playerid1); // I've do that for making player in the team 1
        
}
        case 
1:
        {
            
            
SetPlayerColor(playerid0xFF0000AA); // Red
            
SetPlayerTeam(playerid2); // I've do that for making player in the team 2
        
}
    }
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
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(playeridteam1score);
    
format(newtextsizeof(newtext), "BLUE: %d"team1score);
    
TextDrawSetString(textdrawbluenewtext);   
    
TextDrawShowForPlayer(playeridtextdrawblue);
    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
Reply
#2

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;
}
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)