ShowStats problem
#1

Hy guys i creating Stats in TextDraw-s and dont wonna to show me info of player here is cod:

Код:
stock Stats(playerid)
{

        new string[128],text[128];
        //posao
        if(GetPVarInt(playerid, "Posao") == 1) { text = "Detektiv"; }
        else if(GetPVarInt(playerid, "Posao") == 2) { text = "Advokat"; }
        else if(GetPVarInt(playerid, "Posao") == 3) { text = "Prostitutka"; }
        else if(GetPVarInt(playerid, "Posao") == 4) { text = "Diler Droge"; }
        else if(GetPVarInt(playerid, "Posao") == 5) { text = "Kradljivac Auta"; }
        else if(GetPVarInt(playerid, "Posao") == 7) { text = "Automehanicar"; }
        else if(GetPVarInt(playerid, "Posao") == 8) { text = "Bodyguard"; }
        else if(GetPVarInt(playerid, "Posao") == 9) { text = "Diler Oruzja"; }
        else if(GetPVarInt(playerid, "Posao") == 10) { text = "Farmer"; }
        else if(GetPVarInt(playerid, "Posao") == 12) { text = "Bokser"; }
        else if(GetPVarInt(playerid, "Posao") == 14) { text = "Vozac Autobusa"; }
        else if(GetPVarInt(playerid, "Posao") == 15) { text = "Raznosac Novina"; }
        else if(GetPVarInt(playerid, "Posao") == 16) { text = "Kamiondzija"; }
        else if(GetPVarInt(playerid, "Posao") == 17) { text = "Raznosac Pice"; }
        else if(GetPVarInt(playerid, "Posao") == 18) { text = "Uzgajivac Droge"; }
        else if(GetPVarInt(playerid, "Posao") == 19) { text = "Uzgajivac Droge"; }
        else if(GetPVarInt(playerid, "Posao") == 20) { text = "Svercer Droge"; }
        else if(GetPVarInt(playerid, "Posao") == 21) { text = "Cistac Ulica"; }
        else if(GetPVarInt(playerid, "Posao") == 22) { text = "Svercer Matsa"; }
        else if(GetPVarInt(playerid, "Posao") == 13) { text = "Proizvodac oruzija"; }

        else { text = "Nezaposlen"; } // ako je id posla 0 odnosno ako je igrac nezaposlen
        //
	format(string,sizeof(string),"Ime i prezime : %s~n~~n~Novac: %d$~n~~n~Posao: %s",GetName(playerid),GetPlayerMoney(playerid),text);
	TextDrawSetString(StatsTDLevo[playerid], string); //
    ShowStatsDusan(playerid);//ovo ću objasniti u idućem koraku (korak 4 )
return 1;
}
and here is the command:
Код:
if (strcmp(cmd, "/stats", true) == 0)
  {
	    if(GetPlayerState(playerid) != 2)
	    {
	    	if(Pokrenuti[playerid] == 0)
	    	{
				Stats(playerid);
				Pokrenuti[playerid] = 1;
		}else{SCM(playerid, -1, " Nemozete gledati statse tijekom voћnje !");}
            }
	return 1;
}
Reply
#2

pawn Код:
if (strcmp(cmd, "/stats", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (Pokrenuti[playerid] != 0)
            {
                Stats(playerid, playerid);
                Pokrenuti[playerid] = 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   You are not Logged in !");
            }
        }
        return 1;
    }
Reply
#3

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
pawn Код:
if (strcmp(cmd, "/stats", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (Pokrenuti[playerid] != 0)
            {
                Stats(playerid, playerid);
                Pokrenuti[playerid] = 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   You are not Logged in !");
            }
        }
        return 1;
    }
Not Working :/
Reply
#4

ShowStatsDusan - I guess this function shows the stats textdraw 'StatsTDLevo', so can you show us how it's done?
Reply
#5

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
ShowStatsDusan - I guess this function shows the stats textdraw 'StatsTDLevo', so can you show us how it's done?
Here u go:
Код:
StatsTDLevo[playerid] = TextDrawCreate(148.000000, 142.000000, "Racun");
    TextDrawBackgroundColor(StatsTDLevo[playerid], 255);
    TextDrawFont(StatsTDLevo[playerid], 1);
    TextDrawLetterSize(StatsTDLevo[playerid], 0.500000, 1.000000);
    TextDrawColor(StatsTDLevo[playerid], 12582911);
    TextDrawSetOutline(StatsTDLevo[playerid], 0);
    TextDrawSetProportional(StatsTDLevo[playerid], 1);
    TextDrawSetShadow(StatsTDLevo[playerid], 1);
Reply
#6

So, you're setting the string of the textdraw before creating it? That's wrong.

I'd rather create all the textdraws when the server starts up (i.e. under OnGameModeInit), here's a method of doing so:

pawn Код:
// This code creates a textdraw for each player (Depends on the defination of MAX_PLAYERS).
// It's preferred to put this code either under OnGameModeInit or OnFilterScriptInit
for(new i = 0; i < MAX_PLAYERS; i ++)
{
    StatsTDLevo[i] = TextDrawCreate(148.000000, 142.000000, "Racun");
    TextDrawBackgroundColor(StatsTDLevo[i], 255);
    TextDrawFont(StatsTDLevo[i], 1);
    TextDrawLetterSize(StatsTDLevo[i], 0.500000, 1.000000);
    TextDrawColor(StatsTDLevo[i], 12582911);
    TextDrawSetOutline(StatsTDLevo[i], 0);
    TextDrawSetProportional(StatsTDLevo[i], 1);
    TextDrawSetShadow(StatsTDLevo[i], 1);
}
Also, we'll need to modfiy your ShowStatsDusan function a little - now we need this function to only show the textdraw to a player, so your function has to be just like this:

pawn Код:
stock ShowStatsDusan(playerid)
{
    TextDrawShowForPlayer(playerid, StatsTDLevo[playerid]);
    return 1;
}
And to hide the stats textdraw for a player use:

pawn Код:
TextDrawHideForPlayer(playerid, StatsTDLevo[playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)