Beiträge von Blackshadowscript

    Jeffry ich habe das bei mir so rein gemacht:


    public OnPlayerConnect(playerid)
    {
    if(IsPlayerNPC(playerid)) return 1;
    new nachricht[128];
    format(nachricht,sizeof(nachricht),"Du bist mit der ID %i verbunden.",playerid);
    SendClientMessage(playerid,rot,nachricht);
    //Login/Register:
    new name[MAX_PLAYER_NAME],query[128];
    GetPlayerName(playerid,name,sizeof(name));
    format(query,sizeof(query),"SELECT id FROM user WHERE username='%s' ",name);
    mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
    SendClientMessage(playerid,grün,"Willkommen auf Reallife Version 0.1.4! Wir wünschen euch ein angenehmen Spiel spaß bei uns!");
    //textdraws anzeigen:
    TextDrawShowForPlayer(playerid,Text:uhrzeitLabel);
    TextDrawShowForPlayer(playerid, Jahr);
    SetPlayerColor(playerid,weiß);
    sInfo[playerid][level]=1;
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][firma]=-1;
    return 1;
    }



    avePlayer(playerid)
    {
    if(sInfo[playerid][eingeloggt]==0)return 1;
    //Speichern level,money
    new query[256];
    format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i',fraktion='%i',rang='%i',spawnchange='%i',firma='%i'WHERE id='%i'",sInfo[playerid][level],GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo[playerid][spawnchange],sInfo[playerid][firma],sInfo[playerid][db_id]);
    mysql_function_query(dbhandle,query,false,"","");
    return 1;
    }
    resetPlayer(playerid)
    {
    for(new i=0; i<sizeof(sInfo[]); i++)
    {
    sInfo[playerid][playerInfo:i]=0;
    }
    return 1;
    }


    Befehl
    ocmd:kaufefirmengelaende(playerid,params[])
    {
    for(new i;i<sizeof(Firmengebiete);i++)
    {
    if(IsPlayerInRangeOfPoint(playerid, 4.0, Firmengebiete[i][F_KaufX], Firmengebiete[i][F_KaufY], Firmengebiete[i][F_KaufZ]))
    {
    GetPlayerName(playerid, Firmengebiete[i][F_Besitzer], MAX_PLAYER_NAME);
    //Hier das Label aktualisieren.
    sInfo[playerid][firma]= i;
    if(sInfo[playerid][firma] != -1)return SendClientMessage(playerid,rot,"Fehler: Du Besitzt bereits eine Firma!");
    return SendClientMessage(playerid, 0xFFFFFFFF, "Gekauft.");
    }
    }
    return SendClientMessage(playerid, 0xFF0000FF, "Du bist nich am Kaufpunkt des Firmengeländes!");
    }



    PasswortResponse:
    public OnPasswordResponse(playerid)
    {
    new num_rows,num_fields;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(num_rows==1)
    {
    //passwort Richtig
    sInfo[playerid][eingeloggt] = 1;
    sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][db_id] = cache_get_field_content_int(0,"id",dbhandle);
    SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
    sInfo[playerid][alevel] = cache_get_field_content_int(0,"alevel",dbhandle);
    sInfo[playerid][fraktion] = cache_get_field_content_int(0,"fraktion",dbhandle);
    sInfo[playerid][rang] = cache_get_field_content_int(0,"rang",dbhandle);
    sInfo[playerid][spawnchange] = cache_get_field_content_int(0,"spawnchange",dbhandle);
    sInfo[playerid][firma] =cache_get_field_content_int(0,"firma",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    loadPlayerCars(playerid);


    }
    else
    {
    //Passwort Falsch
    SendClientMessage(playerid,grün,"Du hast dein Passwort falsch eingetippt. Versuche es nochmal!");
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
    }
    return 1;
    }


    Login/Register:
    if(dialogid==DIALOG_LOGIN)
    {
    if(response)
    {
    new name[MAX_PLAYER_NAME],query[128],passwort[35];
    GetPlayerName(playerid,name,sizeof(name));
    if(strlen(inputtext)>0)
    {
    mysql_escape_string(inputtext,passwort,dbhandle);
    format(query,sizeof(query),"SELECT * FROM user WHERE username='%s' AND passwort='%s'",name,passwort);
    mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
    }
    else
    {
    //Keine Eingabe
    SendClientMessage(playerid,grün,"Gibt bitte dein Passwort ein.");
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
    }
    }
    else
    {
    Kick(playerid);
    }
    }
    if(dialogid==DIALOG_REGISTER)
    {
    if(response)
    {
    new name[MAX_PLAYER_NAME],query[128],passwort[35];
    GetPlayerName(playerid,name,sizeof(name));
    if(strlen(inputtext)>5)
    {
    //Registrierungsfunktion
    mysql_escape_string(inputtext,passwort,dbhandle);
    format(query,sizeof(query),"INSERT INTO user (username, passwort, level) VALUES ('%s','%s', '1')",name,passwort);
    mysql_function_query(dbhandle,query,false,"","");
    sInfo[playerid][level]=1;
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][firma]= -1;
    }
    else
    {
    //Kleiner als 4 Zeichen
    SendClientMessage(playerid,helblau,"Dein Passwort muss mindestens 6 Zeichen lang sein.");
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account Erstellung","Gebe bitte nun dein gewünschtes Passwort ein!","Erstellen","Abbrechen");
    }
    }
    else
    {
    Kick(playerid);
    }
    }



    Wenn ich ingame bin und kaufefirmengelände eintippe sagt er mir ich habe schon ein Firmengelände was habe ich falsch gemacht?

    ich habe es jetzt so gemacht:


    ocmd:kaufefirmengelaende(playerid,params[])
    {
    for(new i;i<sizeof(Firmengebiete);i++)
    {
    if(IsPlayerInRangeOfPoint(playerid, 4.0, Firmengebiete[i][F_KaufX], Firmengebiete[i][F_KaufY], Firmengebiete[i][F_KaufZ]))
    {
    GetPlayerName(playerid, Firmengebiete[i][F_Besitzer], MAX_PLAYER_NAME);
    //Hier das Label aktualisieren.
    return SendClientMessage(playerid, 0xFFFFFFFF, "Gekauft.");
    }
    }
    return SendClientMessage(playerid, 0xFF0000FF, "Du bist nich am Kaufpunkt des Firmengeländes!");
    }


    aber wie speicher ich denn nun das gebeit in den Account vom Spieler?


    Ich habe es in mein sInfo gepackt:


    enum playerInfo{
    eingeloggt,
    level,
    db_id,
    alevel,
    fraktion,
    rang,
    spawnchange,
    firma
    }


    OnPlayerConnect:
    public OnPlayerConnect(playerid)
    {
    if(IsPlayerNPC(playerid)) return 1;
    new nachricht[128];
    format(nachricht,sizeof(nachricht),"Du bist mit der ID %i verbunden.",playerid);
    SendClientMessage(playerid,rot,nachricht);
    //Login/Register:
    new name[MAX_PLAYER_NAME],query[128];
    GetPlayerName(playerid,name,sizeof(name));
    format(query,sizeof(query),"SELECT id FROM user WHERE username='%s' ",name);
    mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
    SendClientMessage(playerid,grün,"Willkommen auf Reallife Version 0.1.4! Wir wünschen euch ein angenehmen Spiel spaß bei uns!");
    //textdraws anzeigen:
    TextDrawShowForPlayer(playerid,Text:uhrzeitLabel);
    TextDrawShowForPlayer(playerid, Jahr);
    SetPlayerColor(playerid,weiß);
    sInfo[playerid][level]=1;
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][firma]=1;
    return 1;
    }


    Speichern und Neusetzen des Spielers:
    savePlayer(playerid)
    {
    if(sInfo[playerid][eingeloggt]==0)return 1;
    //Speichern level,money
    new query[256];
    format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i',fraktion='%i',rang='%i',spawnchange='%i',firma='%i'WHERE id='%i'",sInfo[playerid][level],GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo[playerid][spawnchange],sInfo[playerid][firma],sInfo[playerid][db_id]);
    mysql_function_query(dbhandle,query,false,"","");
    return 1;
    }
    resetPlayer(playerid)
    {
    for(new i=0; i<sizeof(sInfo[]); i++)
    {
    sInfo[playerid][playerInfo:i]=0;
    }
    return 1;
    }


    Discinnect:
    public OnPlayerDisconnect(playerid, reason)
    {
    savePlayer(playerid);
    resetPlayer(playerid);
    loadPlayerCars(playerid);
    return 1;
    }


    public OnPasswordResponse(playerid)
    {
    new num_rows,num_fields;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(num_rows==1)
    {
    //passwort Richtig
    sInfo[playerid][eingeloggt] = 1;
    sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][db_id] = cache_get_field_content_int(0,"id",dbhandle);
    SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
    sInfo[playerid][alevel] = cache_get_field_content_int(0,"alevel",dbhandle);
    sInfo[playerid][fraktion] = cache_get_field_content_int(0,"fraktion",dbhandle);
    sInfo[playerid][rang] = cache_get_field_content_int(0,"rang",dbhandle);
    sInfo[playerid][spawnchange] = cache_get_field_content_int(0,"spawnchange",dbhandle);
    sInfo[playerid][firma] =cache_get_field_content_int(0,"firma",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    loadPlayerCars(playerid);


    }
    else
    {
    //Passwort Falsch
    SendClientMessage(playerid,grün,"Du hast dein Passwort falsch eingetippt. Versuche es nochmal!");
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
    }
    return 1;
    }


    ich weiß nun nicht ob es gespeichert wird oder nicht da in der Datenbank immer mit 0 angezeigt wird. Ich will auch das es nur 1mal zu kaufen gibt und man es dann als anderen Spieler nicht kaufen kann mehr

    OnPasswordresponse:
    public OnPasswordResponse(playerid)
    {
    new num_rows,num_fields;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(num_rows==1)
    {
    //passwort Richtig
    sInfo[playerid][eingeloggt] = 1;
    sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    sInfo[playerid][db_id] = cache_get_field_content_int(0,"id",dbhandle);
    SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
    sInfo[playerid][alevel] = cache_get_field_content_int(0,"alevel",dbhandle);
    sInfo[playerid][fraktion] = cache_get_field_content_int(0,"fraktion",dbhandle);
    sInfo[playerid][rang] = cache_get_field_content_int(0,"rang",dbhandle);
    sInfo[playerid][spawnchange] = cache_get_field_content_int(0,"spawnchange",dbhandle);
    sInfo[playerid][firma] =cache_get_field_content_int(0,"firma",dbhandle);
    SetPlayerScore(playerid,sInfo[playerid][level]);
    loadPlayerCars(playerid);


    }
    else
    {
    //Passwort Falsch
    SendClientMessage(playerid,grün,"Du hast dein Passwort falsch eingetippt. Versuche es nochmal!");
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
    }
    return 1;
    }



    Und hier die Dialoge:


    Login/Register:
    if(dialogid==DIALOG_LOGIN)
    {
    if(response)
    {
    new name[MAX_PLAYER_NAME],query[128],passwort[35];
    GetPlayerName(playerid,name,sizeof(name));
    if(strlen(inputtext)>0)
    {
    mysql_escape_string(inputtext,passwort,dbhandle);
    format(query,sizeof(query),"SELECT * FROM user WHERE username='%s' AND passwort=MD5('%s')",name,passwort);
    mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
    }
    else
    {
    //Keine Eingabe
    SendClientMessage(playerid,grün,"Gibt bitte dein Passwort ein.");
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Anmelden","Abbrechen");
    }
    }
    else
    {
    Kick(playerid);
    }
    }
    if(dialogid==DIALOG_REGISTER)
    {
    if(response)
    {
    new name[MAX_PLAYER_NAME],query[128],passwort[35];
    GetPlayerName(playerid,name,sizeof(name));
    if(strlen(inputtext)>5)
    {
    //Registrierungsfunktion
    mysql_escape_string(inputtext,passwort,dbhandle);
    format(query,sizeof(query),"INSERT INTO user (username, passwort, level) VALUES ('%s', MD5('%s'), '1')",name,passwort);
    mysql_function_query(dbhandle,query,false,"","");
    sInfo[playerid][level]=1;
    SetPlayerScore(playerid,sInfo[playerid][level]);
    }
    else
    {
    //Kleiner als 4 Zeichen
    SendClientMessage(playerid,helblau,"Dein Passwort muss mindestens 6 Zeichen lang sein.");
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account Erstellung","Gebe bitte nun dein gewünschtes Passwort ein!","Erstellen","Abbrechen");
    }
    }
    else
    {
    Kick(playerid);
    }
    }