-> MySQL User Abfragen

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Hey, Leute!


    Ich habe nun endlich ein bisschen MySQL gecheckt....
    Nun die Frage: Wie bekomme ich die Informationen eines angegebenen Spielers?
    Kann mir da wer helfen?



    ocmd:checkid(playerid,params[])
    {
    new id, string[128],s1[128],s2[128],s3[128],s4[128],s5[128];
    if(!isPlayerAdmin(playerid,2))return SendClientMessage(playerid,arot,"Du hast nicht den passenden Adminrang.");
    if(sscanf(params,"d",id))return SendClientMessage(playerid,weiß,"Info: /checkid [DatenbankID]");
    s3=mysql_GetInt("players","Level","ID",id);
    s5=mysql_GetInt("players","Geld","ID",id);
    s4=mysql_GetInt("players","Adminlevel","ID",id);
    s1=mysql_GetString("players","Name","ID",id);
    s2=mysql_GetString("players","Passwort","ID",id);
    format(string,sizeof(string),"[Name: %s] [Passwort: %s] [Level: %s] [Adminlevel: %s] [Geld: %s]",s1,s2,s3,s4,s5);
    SendClientMessage(playerid,gelb,string);
    return 1;
    }


    stock mysql_GetInt(Table[], Field[], Where[], Is[])
    {
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    new sqlint = mysql_fetch_int();
    mysql_free_result();
    return sqlint;
    }


    stock mysql_GetString(Table[], Field[], Where[], Is[])
    {
    new query[128], Get[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
    }




    //Errors
    C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(375) : error 035: argument type mismatch (argument 4)C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(375) : error 033: array must be indexed (variable "s3")C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(376) : error 035: argument type mismatch (argument 4)C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(376) : error 033: array must be indexed (variable "s5")C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(377) : error 035: argument type mismatch (argument 4)C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(377) : error 033: array must be indexed (variable "s4")C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(378) : error 035: argument type mismatch (argument 4)C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(379) : error 035: argument type mismatch (argument 4)Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


    8 Errors.

  • Irgendwie habe ich es immer noch nicht kapiert.....
    Ich habe nun folgenden Code und folgenden Error:

    ocmd:checkid(playerid,params[])
    {
    new id, string[128],s1[128],s2[128],s3[128],s4[128],s5[128];
    if(!isPlayerAdmin(playerid,2))return SendClientMessage(playerid,arot,"Du hast nicht den passenden Adminrang.");
    if(sscanf(params,"i",id))return SendClientMessage(playerid,weiß,"Info: /checkid [DatenbankID]");
    format(s3,sizeof(s3),"%d",mysql_GetInt("players","Level","ID",id));
    format(s5,sizeof(s5),"%d$",mysql_GetInt("players","Geld","ID",id));
    format(s4,sizeof(s4),"%d",mysql_GetInt("players","Adminlevel","ID",id));
    format(s1,sizeof(s1),"%s",mysql_GetString("players","Name","ID",id));
    format(s2,sizeof(s2),"%s",mysql_GetString("players","Passwort","ID",id));
    //s3=mysql_GetInt("players","Level","ID",id);
    //s5=mysql_GetInt("players","Geld","ID",id);
    //s4=mysql_GetInt("players","Adminlevel","ID",id);
    //s1=mysql_GetString("players","Name","ID",id);
    //s2=mysql_GetString("players","Passwort","ID",id);
    format(string,sizeof(string),"[Name: %s] [Passwort: %s] [Level: %s] [Adminlevel: %s] [Geld: %s]",s1,s2,s3,s4,s5);
    SendClientMessage(playerid,gelb,string);
    return 1;
    }



    //Error
    C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(375) : error 035: argument type mismatch (argument 4)
    C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(376) : error 035: argument type mismatch (argument 4)
    C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(377) : error 035: argument type mismatch (argument 4)
    C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(378) : error 035: argument type mismatch (argument 4)
    C:\Users\Kevin\Desktop\Sa-Mp 0.3x\gamemodes\nScript.pwn(379) : error 035: argument type mismatch (argument 4)
    Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    5 Errors.