Problem with Show String in /stats command
#1

I confuse about this.

I load my database like this.
Код:
stock LoadDataString(playerid)
{
    new query[300], pName[24], savingstring[10];
    GetPlayerName(playerid, pName, 24);
    format(query, sizeof(query), "SELECT * FROM `playerchar` WHERE `charname` = '%s'", pName);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
	     mysql_fetch_field_row(savingstring[1], "username"); strmid(PlayerInfo[playerid][uName], savingstring[1], 0, strlen(savingstring[1]), 255);
	     mysql_fetch_field_row(savingstring[2], "origin"); strmid(PlayerInfo[playerid][pOrigin], savingstring[2], 0, strlen(savingstring[2]), 255);
    }
    mysql_free_result();
}
and my command /stats like this.
Код:
CMD:stats(playerid, params[])
{
        if(IsPlayerConnected(playerid))
        {
	         new str[128];
                 format(str, sizeof(str), "Username: %s | Origin: %s", PlayerInfo[playerid][uName], PlayerInfo[playerid][pOrigin]);
	         SendClientMessage(playerid ,0xFFFFFFAA, str);
	         return 1;
        }
        return SendClientMessage(playerid, 0xAFAFAFAA, "Kamu harus login terlebih dahulu untuk menggunakan command ini.");
}
and this showed when i ingame.


why i found two times same word?
please help!
Reply
#2

Any one can help me? please..
Reply
#3

BUMP, please help...
Reply
#4

Hello!

Try this:
PHP код:
stock LoadDataString(playerid)
{
    new 
query[300],pName[24];
    
GetPlayerName(playerid,pName,sizeof(pName));
    
format(query,sizeof query,"SELECT * FROM `playercar` WHERE `charname`='%s'",pName);
    
mysql_query(query);
    
mysql_store_result();
    while(
mysql_fetch_row_format(quey,"|"))
    {
        
mysql_fetch_field_row(PlayerInfo[playerid][uName],"username");
        
mysql_fetch_field_row(PlayerInfo[playerid][pOrigin],"origin");
    }
    
mysql_free_result();

Your problem is that you forgot to declare the length of the string where you save this:
PHP код:
savingstring[10]; 
You can put the "username" and the "origin" directly in the arrays.
Reply
#5

Код HTML:
 while(mysql_fetch_row_format(query,"|"))
    {
	     mysql_fetch_field_row(savingstring[1], "username"); strmid(PlayerInfo[playerid][uName], savingstring[1], 0, strlen(savingstring[1]), 255);
	     mysql_fetch_field_row(savingstring[2], "origin"); strmid(PlayerInfo[playerid][pOrigin], savingstring[2],  strlen(savingstring[1]), strlen(savingstring[2]), 255);
    }
i think you forgot to limit your string start with
PHP код:
strmid(string"Extract 'HELLO' without the !!!!: HELLO!!!!"3439); //string contains "HELLO" 
Reply
#6

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Try this:
PHP код:
stock LoadDataString(playerid)
{
    new 
query[300],pName[24];
    
GetPlayerName(playerid,pName,sizeof(pName));
    
format(query,sizeof query,"SELECT * FROM `playercar` WHERE `charname`='%s'",pName);
    
mysql_query(query);
    
mysql_store_result();
    while(
mysql_fetch_row_format(quey,"|"))
    {
        
mysql_fetch_field_row(PlayerInfo[playerid][uName],"username");
        
mysql_fetch_field_row(PlayerInfo[playerid][pOrigin],"origin");
    }
    
mysql_free_result();

Your problem is that you forgot to declare the length of the string where you save this:
PHP код:
savingstring[10]; 
You can put the "username" and the "origin" directly in the arrays.
i have try this and my /stats ingame is the same. I can't show my /stats ingame like my database.
Reply
#7

Quote:
Originally Posted by gurmani11
Посмотреть сообщение
Код HTML:
 while(mysql_fetch_row_format(query,"|"))
    {
	     mysql_fetch_field_row(savingstring[1], "username"); strmid(PlayerInfo[playerid][uName], savingstring[1], 0, strlen(savingstring[1]), 255);
	     mysql_fetch_field_row(savingstring[2], "origin"); strmid(PlayerInfo[playerid][pOrigin], savingstring[2],  strlen(savingstring[1]), strlen(savingstring[2]), 255);
    }
i think you forgot to limit your string start with
PHP код:
strmid(string"Extract 'HELLO' without the !!!!: HELLO!!!!"3439); //string contains "HELLO" 
Can you give me example? please..
Reply
#8

Try it
PHP код:
stock LoadDataString(playerid)
{
    new 
query[300], pName[24], savingstr1[10], savingstr2[10];
    
GetPlayerName(playeridpName24);
    
format(querysizeof(query), "SELECT * FROM `playerchar` WHERE `charname` = '%s'"pName);
    
mysql_query(query);
    
mysql_store_result();
    while(
mysql_fetch_row_format(query,"|"))
    {
         
mysql_fetch_field_row(savingstr1"username");
             
strmid(PlayerInfo[playerid][uName], savingstr10strlen(savingstr1));
         
mysql_fetch_field_row(savingstr2"origin");
             
strmid(PlayerInfo[playerid][pOrigin], savingstr20strlen(savingstr2));
    }
    
mysql_free_result();

Reply
#9

Quote:
Originally Posted by gurmani11
Посмотреть сообщение
Try it
PHP код:
stock LoadDataString(playerid)
{
    new 
query[300], pName[24], savingstr1[10], savingstr2[10];
    
GetPlayerName(playeridpName24);
    
format(querysizeof(query), "SELECT * FROM `playerchar` WHERE `charname` = '%s'"pName);
    
mysql_query(query);
    
mysql_store_result();
    while(
mysql_fetch_row_format(query,"|"))
    {
         
mysql_fetch_field_row(savingstr1"username");
             
strmid(PlayerInfo[playerid][uName], savingstr10strlen(savingstr1));
         
mysql_fetch_field_row(savingstr2"origin");
             
strmid(PlayerInfo[playerid][pOrigin], savingstr20strlen(savingstr2));
    }
    
mysql_free_result();

i use it can't show anything, but i add this.
Код:
 {
	     mysql_fetch_field_row(savingstr1, "username");
		 	strmid(PlayerInfo[playerid][uName], savingstr1, 0, strlen(savingstr1), 255);
	     mysql_fetch_field_row(savingstr2, "origin");
		 	strmid(PlayerInfo[playerid][pOrigin], savingstr2, 0, strlen(savingstr2), 255);
    }
Show the origin success, but not username.
Reply
#10

Please, someone help me ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)