[MySQL] How to return name from SQLID?
#1

I want to return name from SQLID:

EDIT: I ve tried to do this to make it but it seems wrong

PHP Code:
Plant_GetOwner(sqlid)
{
    new
        
query[128];
    
format(querysizeof(query), "SELECT `Character` FROM `characters` WHERE `ID` = '%d'"ReturnName(sqlid));
    
mysql_tquery(g_iHandlequery"OnQueryFinished""dd"sqlidTHREAD_FIND_USERNAME);
    return 
query;

and the result is:


https://imgur.com/a/PjwRQAy

why?

thank you !


EDIT: I tried to make another way, to get player name on create the plant and insert to database but it happens this..

format(MarihuanaInfo[i][PlantBy], 24, Name(playerid))


https://imgur.com/a/Znbjfik

in database name is: KАЕд

why this happens?!
Reply
#2

show function GetPlayerSQLID
Reply
#3

Quote:
Originally Posted by Florin48
View Post
show function GetPlayerSQLID
PHP Code:
GetPlayerSQLID(playerid)
{
    return (
PlayerData[playerid][pID]);

lol
Reply
#4

The will be returned by OnQueryFinished, not by Plant_GetOwner. Why? Because it's threaded query right here.
If you want Plant_GetOwner return the name, use a simple query, cache the result, obtain the name and delete the cache.
Reply
#5

Quote:
Originally Posted by Dayrion
View Post
The will be returned by OnQueryFinished, not by Plant_GetOwner. Why? Because it's threaded query right here.
If you want Plant_GetOwner return the name, use a simple query, cache the result, obtain the name and delete the cache.
I'm very noob in this, i just domine half good variable and comparatives, i'm trying to understand for loops and mysql too but i dont know if no one show me, when i see code i analyze it and i understand why that is do like that, how to return the name from SQLID?

i'm still trying and restarting server to see if works.. :S
Reply
#6

Help
Reply
#7

Check that: https://sampwiki.blast.hk/wiki/MySQL/R40

PHP Code:
Plant_GetOwner(sqlid

    new 
        
query[128],
        
Cache:query_cache
    
format(querysizeof(query), "SELECT `Character` FROM `characters` WHERE `ID` = '%d'"ReturnName(sqlid)); 
    
query_cache mysql_query(g_iHandlequery"OnQueryFinished""dd"sqlidTHREAD_FIND_USERNAME);
    if(
cache_num_rows())
        
cache_get_value_index(00query);
    else
        
strcpy(query"N/A"); 
    
cache_delete(query_cache);
    return 
query

Reply
#8

Quote:
Originally Posted by Dayrion
View Post
Check that: https://sampwiki.blast.hk/wiki/MySQL/R40

PHP Code:
Plant_GetOwner(sqlid

    new 
        
query[128],
        
Cache:query_cache
    
format(querysizeof(query), "SELECT `Character` FROM `characters` WHERE `ID` = '%d'"ReturnName(sqlid)); 
    
query_cache mysql_query(g_iHandlequery"OnQueryFinished""dd"sqlidTHREAD_FIND_USERNAME);
    if(
cache_num_rows())
        
cache_get_value_index(00query);
    else
        
strcpy(query"N/A"); 
    
cache_delete(query_cache);
    return 
query

Yes man, i tried to look but the functions are not the same? in mine mysql_format is directly format(query..
format(query, sizeof(query),

and mysql_query too doesn't exist in my gamemode, wtf but mysql_tquery yes,
query_cache doesn't exist in my gm.. i dont understand nothing, but i solved it in other ways..


EDIT: It seems no error on compile, i go rewrite my code to try your function if works, i've get solved it with other ways, create varchar ownerPlant and get player name on creating the plant.. fast solution XD becouse i dont found how to return player sqlid name

EDIT2:

Code:
C:\Reality Roleplay\gamemodes\sqlidnameroleplay.pwn(8465) : error 035: argument type mismatch (argument 3)
C:\Reality Roleplay\gamemodes\sqlidnameroleplay.pwn(8467) : error 017: undefined symbol "cache_get_value_index"
C:\Reality Roleplay\gamemodes\sqlidnameroleplay.pwn(8469) : error 017: undefined symbol "strcpy"
EDIT3: https://sampwiki.blast.hk/wiki/MySQL/R33

it seems that i use this becouse i use cache_get_field_content, right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)