SA-MP Forums Archive
[HELP] Can't figure it out! - 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)
+--- Thread: [HELP] Can't figure it out! (/showthread.php?tid=567366)



[HELP] Can't figure it out! - Fantje - 13.03.2015

Heey guys,

I tried a lot but I don't know how to make a textdraw with KILLS & DEATHS that load the kills & deaths from users file.

I have a command: /stats and there you can see how many times you are killed and the deaths. I want a textdraw on the right side so you have it without a command. HOW?

Command script:

PHP код:
CMD:stats(playerid,params[]) {
    new 
string[100], pDeathsplayer1hms,playername[MAX_PLAYER_NAME];
    if(
isnull(params)) player1 playerid;
    else 
player1 strval(params);
    if(
IsPlayerConnected(player1)) {
        
TotalGameTime(player1hms);
        
GetPlayerName(player1playernamesizeof(playername));
         if(
PlayerInfo[player1][Deaths] == 0pDeaths 1; else pDeaths PlayerInfo[player1][Deaths];
         new 
str[120], str1[100], str2[100];
         
format(strsizeof(str),"| ------ | %s's Status | ------- |"PlayerName2(player1));
        
format(string,sizeof(string),"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f"GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);
        
format(str1sizeof(str1),"Admin Level: %d | Moderator: %s | Rank: %s | Team: %s | Class: %s"PlayerInfo[player1][Level], PlayerInfo[player1][Helper] ? ("Yes") : ("No"), GetRankName(player1), GetTeamName(player1), GetClass(player1));
        
format(str2sizeof(str2),"TimePlayed: [%d] hrs [%d] mins [%d] secs"hms);
        
SendClientMessage(playerid0xFFFFFFFF,str);
        
SendClientMessage(playerid0xAAAAAAFF,string);
        
SendClientMessage(playerid0xAAAAAAFF,str1);
        
SendClientMessage(playerid0xAAAAAAFF,str2);
        
SendClientMessage(playerid0xFFFFFFFF,"| ---------------------------------------------------- |");
    } else return 
SendClientMessage(playeridred"Player Not Connected!");
    return 
1;

You can see this from the command:
PHP код:
"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f"GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths); 
Textdraw:

PHP код:
Web TextDrawCreate(485.00000010.000000"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f");
    
TextDrawBackgroundColor(Web255);
    
TextDrawFont(Web1);
    
TextDrawLetterSize(Web0.3300001.200000);
    
TextDrawColor(Web, -1);
    
TextDrawSetOutline(Web1);
    
TextDrawSetProportional(Web1);
    
TextDrawSetShadow(Web,1); 
So I wanna put this in my textdraw to show kills and deaths,

HOW?


Re: [HELP] Can't figure it out! - CalvinC - 13.03.2015

You use format in your /stats command, do the same with your textdraw.
Quote:

format(str, sizeof(str), "Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f", GetPlayerScore(playerid), Rest of the money, kills deaths and etc. info here);
Web = TextDrawCreate(485.000000, 10.000000, str);

Also, it's just a complete waste to define str, string, str2 and etc. in your /stats command, you can just use 1 like so:
pawn Код:
format(str, sizeof(str), "Stuff");
SendClientMessage(playerid, -1, str);
format(str, sizeof(str), "Stuff");
SendClientMessage(playerid, -1, str);
Which only needs to allocate memory to 1 array.
Instead of using multiple arrays:
pawn Код:
format(str, sizeof(str), "Stuff");
format(str2, sizeof(str2), "Stuff");
SendClientMessage(playerid, -1, str);
SendClientMessage(playerid, -1, str2);



Re: [HELP] Can't figure it out! - Fantje - 13.03.2015

Mmm, I am noob so I don't know how... Can you make the textdraw? ( sorry )


Re: [HELP] Can't figure it out! - CalvinC - 13.03.2015

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
pawn Код:
format(str, sizeof(str), "Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f", GetPlayerScore(playerid), Rest of the money, kills deaths and etc. info here);
Web = TextDrawCreate(485.000000, 10.000000, str);
I told you how to do it, you should do it somewhat like that.


Re: [HELP] Can't figure it out! - Fantje - 13.03.2015

Thanks but:

PHP код:
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1410) : error 017undefined symbol "str"
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1410) : error 017undefined symbol "str"
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1410) : error 029invalid expressionassumed zero
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1410) : fatal error 107too many error messages on one line 
My lines:

PHP код:
format(strsizeof(str), "Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f"GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);
    
Web TextDrawCreate(485.00000010.000000str);
    
TextDrawBackgroundColor(Web255);
    
TextDrawFont(Web1);
    
TextDrawLetterSize(Web0.3300001.200000);
    
TextDrawColor(Web, -1);
    
TextDrawSetOutline(Web1);
    
TextDrawSetProportional(Web1);
    
TextDrawSetShadow(Web,1); 



Re: [HELP] Can't figure it out! - CalvinC - 13.03.2015

You have to declare a str array like in /stats.
pawn Код:
new str[100];



Re: [HELP] Can't figure it out! - Fantje - 13.03.2015

If I do that I just get this:

PHP код:
C:\Users\Administrator\Desktop\ProjectSvT\pawno\include\fixes2.inc(18) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\pawno\include\fixes2.inc(42) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : error 017undefined symbol "player1"
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(2921) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3347) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3363) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3379) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3395) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3411) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3530) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3682) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3829) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(3976) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(4123) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(4270) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(4417) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(4565) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(4712) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(4859) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(5006) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(5153) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(5300) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(5447) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(5594) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(5741) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(5888) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(6035) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(6540) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(7166) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(7224) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(7235) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(8151) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(8180) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(8206) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(8251) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(9978) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(10516) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(10546) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(10578) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(10594) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(10824) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(11929) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(12032) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(12051) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(12389) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(13397) : warning 219local variable "str" shadows a variable at a preceding level
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(13656) : warning 219local variable "str" shadows a variable at a preceding level
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase


1 Error




Re: [HELP] Can't figure it out! - CalvinC - 13.03.2015

You're trying to declare it globally i guess, make sure you declare it inside the same function/callback as the one you're creating the textdraw in, otherwise rename it to something else you don't use.


Re: [HELP] Can't figure it out! - Fantje - 13.03.2015

okay


Re: [HELP] Can't figure it out! - Fantje - 13.03.2015

Your code don't give errors but when I go ingame nothing shows ( by score, money, kills, deaths , ratio). It shows: 0 everywhere
//
I have done someting:

PHP код:
new string[100], pDeathsplayer1hms,playername[MAX_PLAYER_NAME];
    if(
isnull(params)) player1 playerid;
    else 
player1 strval(params);
    if(
IsPlayerConnected(player1)) {
     
TotalGameTime(player1hms);
    
GetPlayerName(player1playernamesizeof(playername));
    if(
PlayerInfo[player1][Deaths] == 0pDeaths 1; else pDeaths PlayerInfo[player1][Deaths];
    new 
str[120], str1[100], str2[100];
    
format(strsizeof(str),"| ------ | %s's Status | ------- |"PlayerName2(player1));
    
format(string,sizeof(string),"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f"GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);
    
Web TextDrawCreate(485.00000010.000000str);
    
TextDrawBackgroundColor(Web255);
    
TextDrawFont(Web1);
    
TextDrawLetterSize(Web0.3300001.200000);
    
TextDrawColor(Web, -1);
    
TextDrawSetOutline(Web1);
    
TextDrawSetProportional(Web1);
    
TextDrawSetShadow(Web,1); 
Error:

PHP код:
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : error 017undefined symbol "params"
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : error 029invalid expressionassumed zero
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : error 017undefined symbol "params"
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : fatal error 107too many error messages on one line 
When I define params (new params; ):

PHP код:
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : error 028invalid subscript (not an array or too many subscripts): "params"
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : error 029invalid expressionassumed zero
C
:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : error 028invalid subscript (not an array or too many subscripts): "params"
C:\Users\Administrator\Desktop\ProjectSvT\gamemodes\SvTMike.pwn(1411) : fatal error 107too many error messages on one line