Frage zu MySQL R39-3

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
  • Hallo,


    ich wollte mich mal etwas mit meinem Script und der MySQL R39-3 (BlueG) auseinandersetzen.
    Nun habe ich eine Frage: Muss jeder Query auf ein Callback "antworten"?


    Wenn nein, kann mir jemand ein Beispiel geben, wie ich das bei folgendem Code umschreiben kann?
    new q[128],w;
    format(q,sizeof q,"SELECT `ID`, `Status`, `Model` FROM `Playercars` WHERE `Owner` = '%s'",pInfo[playerid][pName]);
    //mysql_format(dbHandle,q,sizeof q,"SELECT `ID`, `Status`, `Model` FROM `Playercars` WHERE `Owner` = '%e'",pInfo[playerid][pName]);
    mysql_query(q);
    mysql_store_result();
    if(mysql_num_rows()) {
    while(mysql_fetch_row(str)) {
    w++;
    new st,md,id;
    sscanf(str,"p<|>ddd",id,st,md);
    switch(w) {
    case 1: {
    PlayerTextDrawSetPreviewModel(playerid, Stats[29][playerid], md);
    cStats[0][playerid] = id;
    if(st == 1) { PlayerTextDrawBackgroundColor(playerid, Stats[29][playerid], 0x00D900FF); format(in,sizeof in,"%s~n~~g~Nicht Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[33][playerid], in); }
    else if(st == 0) { PlayerTextDrawBackgroundColor(playerid, Stats[29][playerid], 0xFF0000FF); format(in,sizeof in,"%s~n~~r~Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[33][playerid], in); }
    PlayerTextDrawShow(playerid, Stats[29][playerid]), PlayerTextDrawShow(playerid, Stats[33][playerid]);
    }
    case 2: {
    PlayerTextDrawSetPreviewModel(playerid, Stats[30][playerid], md);
    cStats[1][playerid] = id;
    if(st == 1) { PlayerTextDrawBackgroundColor(playerid, Stats[30][playerid], 0x00D900FF); format(in,sizeof in,"%s~n~~g~Nicht Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[34][playerid], in); }
    else if(st == 0) { PlayerTextDrawBackgroundColor(playerid, Stats[30][playerid], 0xFF0000FF); format(in,sizeof in,"%s~n~~r~Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[34][playerid], in); }
    PlayerTextDrawShow(playerid, Stats[29][playerid]), PlayerTextDrawShow(playerid, Stats[33][playerid]), PlayerTextDrawShow(playerid, Stats[30][playerid]), PlayerTextDrawShow(playerid, Stats[34][playerid]);
    }
    }
    }
    }
    mysql_free_result();


    Jeffry: vielleicht :)


    lg
    Deagle

  • Bei einem SELECT: Ja. Außer du verzichtest explizit darauf, was nicht empfohlen ist. Also: Ja.
    Bei einem UPDATE/INSERT: Nicht unbedingt, da du da keinen Cache benötigst (es kommt ja nichts (bzw. nicht immer) was zurück).

  • new q[128],w;
    format(q,sizeof q,"SELECT `ID`, `Status`, `Model` FROM `Playercars` WHERE `Owner` = '%s'",pInfo[playerid][pName]);
    //mysql_format(dbHandle,q,sizeof q,"SELECT `ID`, `Status`, `Model` FROM `Playercars` WHERE `Owner` = '%e'",pInfo[playerid][pName]);
    mysql_query(q);
    mysql_store_result();
    if(mysql_num_rows()) {
    while(mysql_fetch_row(str)) {
    w++;
    new st,md,id;
    sscanf(str,"p<|>ddd",id,st,md);
    switch(w) {
    case 1: {
    PlayerTextDrawSetPreviewModel(playerid, Stats[29][playerid], md);
    cStats[0][playerid] = id;
    if(st == 1) { PlayerTextDrawBackgroundColor(playerid, Stats[29][playerid], 0x00D900FF); format(in,sizeof in,"%s~n~~g~Nicht Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[33][playerid], in); }
    else if(st == 0) { PlayerTextDrawBackgroundColor(playerid, Stats[29][playerid], 0xFF0000FF); format(in,sizeof in,"%s~n~~r~Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[33][playerid], in); }
    PlayerTextDrawShow(playerid, Stats[29][playerid]), PlayerTextDrawShow(playerid, Stats[33][playerid]);
    }
    case 2: {
    PlayerTextDrawSetPreviewModel(playerid, Stats[30][playerid], md);
    cStats[1][playerid] = id;
    if(st == 1) { PlayerTextDrawBackgroundColor(playerid, Stats[30][playerid], 0x00D900FF); format(in,sizeof in,"%s~n~~g~Nicht Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[34][playerid], in); }
    else if(st == 0) { PlayerTextDrawBackgroundColor(playerid, Stats[30][playerid], 0xFF0000FF); format(in,sizeof in,"%s~n~~r~Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[34][playerid], in); }
    PlayerTextDrawShow(playerid, Stats[29][playerid]), PlayerTextDrawShow(playerid, Stats[33][playerid]), PlayerTextDrawShow(playerid, Stats[30][playerid]), PlayerTextDrawShow(playerid, Stats[34][playerid]);
    }
    }
    }
    }
    mysql_free_result();


    zu


    new dbhandle; //Oben erstellen lassen


    dbhandle = mysql_connect(host, user, data, pass, port, autoreconnect, pool); //Verbindungsaufbau
    switch(mysql_errno(dbhandle)){
    case false:{
    // Verbindung steht
    }
    default: {
    // Verbindung fehlt
    }
    }



    mysql_format(dbhandle, q, sizeof q, "SELECT `ID`, `Status`, `Model` FROM `Playercars` WHERE `Owner` = '%e'", pInfo[playerid][pName]),
    mysql_pquery(dbhandle, q, "LoadingModel", "i", playerid); //Query ausführen



    //Callback
    static LoadingModel(playerid);
    public LoadingModel(playerid){
    if(cache_get_row_count(dbhandle) > 0){
    new w;
    for(new i;i<cache_get_row_count(dbhandle);i++){
    new st,md,id;
    w++,
    st = cache_get_field_content_int(i, "Status", dbhandle),
    md = cache_get_field_content_int(i, "Model", dbhandle),
    id = cache_get_field_content_int(i, "ID", dbhandle);
    switch(w) {
    case 1:{
    PlayerTextDrawSetPreviewModel(playerid, Stats[29][playerid], md);
    cStats[0][playerid] = id;
    if(st == 1) { PlayerTextDrawBackgroundColor(playerid, Stats[29][playerid], 0x00D900FF); format(in,sizeof in,"%s~n~~g~Nicht Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[33][playerid], in); }
    else if(st == 0) { PlayerTextDrawBackgroundColor(playerid, Stats[29][playerid], 0xFF0000FF); format(in,sizeof in,"%s~n~~r~Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[33][playerid], in); }
    PlayerTextDrawShow(playerid, Stats[29][playerid]), PlayerTextDrawShow(playerid, Stats[33][playerid]);
    }
    case 2:{
    PlayerTextDrawSetPreviewModel(playerid, Stats[30][playerid], md);
    cStats[1][playerid] = id;
    if(st == 1) { PlayerTextDrawBackgroundColor(playerid, Stats[30][playerid], 0x00D900FF); format(in,sizeof in,"%s~n~~g~Nicht Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[34][playerid], in); }
    else if(st == 0) { PlayerTextDrawBackgroundColor(playerid, Stats[30][playerid], 0xFF0000FF); format(in,sizeof in,"%s~n~~r~Defekt",PlayerVehicle[md-400]); PlayerTextDrawSetString(playerid, Stats[34][playerid], in); }
    PlayerTextDrawShow(playerid, Stats[29][playerid]), PlayerTextDrawShow(playerid, Stats[33][playerid]), PlayerTextDrawShow(playerid, Stats[30][playerid]), PlayerTextDrawShow(playerid, Stats[34][playerid]);
    }
    }
    }
    }
    }


    Orientiere dich mal an dem Quellcode.


    mfg :thumbup:

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen