PDA

View Full Version : ShowStats problem


Dusan01
07/11/2012, 06:24 PM
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;
}

cecko1235
07/11/2012, 06:47 PM
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;
}

Dusan01
07/11/2012, 07:10 PM
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 :/

[KHK]Khalid
07/11/2012, 08:56 PM
ShowStatsDusan - I guess this function shows the stats textdraw 'StatsTDLevo', so can you show us how it's done?

Dusan01
08/11/2012, 04:14 AM
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);

[KHK]Khalid
08/11/2012, 08:12 PM
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:


// 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:


stock ShowStatsDusan(playerid)
{
TextDrawShowForPlayer(playerid, StatsTDLevo[playerid]);
return 1;
}


And to hide the stats textdraw for a player use:

TextDrawHideForPlayer(playerid, StatsTDLevo[playerid]);