MySQL Plugin ???

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
  • Ja,
    Ist es


    SA-MP Dedicated Server
    ----------------------
    v0.3x, (C)2005-2013 SA-MP Team


    [20:38:52] filterscripts = "" (string)
    [20:38:52]
    [20:38:52] Server Plugins
    [20:38:52] --------------
    [20:38:52] Loading plugin: mysql
    [20:38:52]


    > MySQL plugin R7 successfully loaded.


    [20:38:52] Loaded.
    [20:38:52] Loaded 1 plugins.


    [20:38:52]
    [20:38:52] Filterscripts
    [20:38:52] ---------------
    [20:38:52] Loaded 0 filterscripts.


    [20:38:52] Script[gamemodes/MYSQLR7.amx]: Run time error 19: "File or function is not found"
    [20:38:52] Number of vehicle models: 0

  • genau daher habe ich die
    Auch DANKE
    Ich Liebe dich


    Das besteht allerdings aus einem Ordner
    Soll ich den in den Plugin Ordner verschieben??
    Oder wie


    Generel gibt es wie schon gesagt eine wzeite version

    #include <a_samp>
    #include <a_mysql>


    #undef MAX_PLAYERS
    #define MAX_PLAYERS (50)
    #define STR_LEN (450)


    #define DIALOG_REGISTER_ACCEPT (0)
    #define DIALOG_REGISTER (1)
    #define DIALOG_LOGIN (2)



    #define PlayerName(%0) PlayerInfo[%0][pName]
    #define DIALOG_REGISTER_ACCEPT_TEXT "Willkommen auf unserem Server,\nwenn sie sich Registrieren wollen so klicken sie auf {ADFF2F}Weiter"


    enum pStats
    {
    pName[20],
    pPassword[129],
    pAge,
    pCountry[20],
    pLevel,
    pAdmin,
    pDonate,
    pGender[10],
    pMoney,
    pBank,
    Float:pPosX,
    Float:pPosY,
    Float:pPosZ,
    pVW,
    pInt,
    pRank,
    pFraction,
    pCarlic,
    pBikelic,
    pPlanelic,
    pLKWlic,
    pHelilic,
    Float:pHealth,
    Float:pArmour,
    pBan,
    pRegdate[20],
    pLastLogin[20],
    }
    new PlayerInfo[MAX_PLAYERS][pStats],
    bool:player_loged_in[MAX_PLAYERS char],
    enter_password_try[MAX_PLAYERS char],
    m_connect;


    native WP_Hash(buffer[], len, const str[]);


    forward OnPlayerLoadPlayerData(playerid);
    forward OnPlayerCheckAccount(playerid);
    forward LoginCamera(playerid);


    new ALLSTRING[64],
    Hash[129],
    Query[STR_LEN];


    main(){ }
    public OnGameModeInit()
    {
    SetGameModeText("Blank");
    mysql_debug(true);
    Databaseconnect();
    //CreateTables();
    return 1;
    }
    public OnGameModeExit()
    {
    for(new i; i < MAX_PLAYERS; ++i)if(player_loged_in{i})SavePlayerData(i),player_loged_in{i}=false;
    return 1;
    }
    public OnPlayerConnect(playerid)
    {
    strdel(Query,0,STR_LEN);
    for(new x; pStats:x < pStats; x++) PlayerInfo[playerid][pStats:x] = 0;
    GetPlayerName(playerid,PlayerInfo[playerid][pName],20);
    SendClientMessage(playerid,-1,"Willkommen auf dem Server");
    return 1;
    }


    public OnPlayerDisconnect(playerid, reason)
    {
    if(player_loged_in{playerid}){
    SavePlayerData(playerid);
    player_loged_in{playerid}=false;
    enter_password_try{playerid}=0;
    }
    return 1;
    }


    public OnPlayerSpawn(playerid)
    {
    if(player_loged_in{playerid}==false)return Kick(playerid);
    return 1;
    }
    public OnPlayerRequestClass(playerid, classid)
    {
    TogglePlayerSpectating(playerid,1);
    SetTimerEx("LoginCamera", 100, false, "i", playerid);
    return 1;
    }
    public LoginCamera(playerid)
    {
    SetPlayerCameraPos(playerid,-201.4289,1372.9482,67.0541);
    SetPlayerCameraLookAt(playerid,204.4058,0,0);
    mysql_format(m_connect,Query,"SELECT `Password`,`LastLogin` FROM `accounts` WHERE `Name` = '%e'",PlayerName(playerid));
    mysql_function_query(m_connect,Query,true,"OnPlayerCheckAccount","i", playerid);
    return 1;
    }
    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    switch(dialogid){
    case DIALOG_REGISTER_ACCEPT:{
    if(response)return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registrierung","Bitte gebe dein gewünschtes Passwort hier ein","Registrieren","Abbrechen");
    else Kick(playerid);
    }
    case DIALOG_REGISTER:{
    if(response){
    if(strlen(inputtext) > 32 || strlen(inputtext) < 4) {
    SendClientMessage(playerid,-1,"Dein Passwort muss mindestens 4 Zeichen oder darf Maximal 16 Zeichen enthalten!");
    return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registrierung","Bitte gebe dein gewünschtes Passwort hier ein","Registrieren","Abbrechen");
    }else{
    WP_Hash(PlayerInfo[playerid][pPassword], 129, inputtext);
    strdel(Query,0,STR_LEN);
    mysql_format(m_connect,Query,"INSERT INTO `accounts` (`Name`, `Password`, `Age`, `Country`, `Level`, `Admin`, `Donate`, `Gender`, `Money`, `Bank`, `X`, `Y`, `Z`, `VW`, `Interior`, `Rank`, `Fraction`, `Carlic`, `Bikelic`, `Planelic`, `LKWlic`, `Helilic`, `Health`, `Armour`, `Ban`,`RegDate`,`LastLogin`) VALUES ('%s', '%s', '0', '0', '0', '0', '0', '0', '0', '0', '155.8156', '-1963.1462', '3.7734', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',NOW(),NOW())",
    PlayerInfo[playerid][pName],PlayerInfo[playerid][pPassword]);
    mysql_function_query(m_connect,Query,false,"","");
    return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","Gebe dein Passwort ein","Anmelden","Abbrechen");
    }
    }else return Kick(playerid);
    }
    case DIALOG_LOGIN:{
    if(response){
    strdel(Hash,0,sizeof(Hash));
    WP_Hash(Hash, 129, inputtext);
    if(!strcmp(PlayerInfo[playerid][pPassword], Hash)){
    strdel(Query,0,STR_LEN);
    mysql_format(m_connect,Query,"SELECT * FROM `accounts` WHERE `Name` = '%e'",PlayerName(playerid));
    mysql_function_query(m_connect,Query,true,"OnPlayerLoadPlayerData","i",playerid);
    SendClientMessage(playerid,-1,"Du hast dich erfolgreich eingloggt!");
    }else{
    strdel(ALLSTRING,0,sizeof(ALLSTRING));
    format(ALLSTRING,64,"Passworteingabe | Letzer Login: {FF8C00}%s",PlayerInfo[playerid][pLastLogin]);
    SendClientMessage(playerid,-1,"Dein Account wurde gefunden. Bitte logge dich ein.");
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login",ALLSTRING,"Anmelden","Abbrechen");
    enter_password_try{playerid}++;
    strdel(ALLSTRING,0,sizeof(ALLSTRING));
    format(ALLSTRING,64,"Du hast noch %d Versuche!",(3-enter_password_try{playerid}));
    SendClientMessage(playerid,-1,ALLSTRING);
    if(enter_password_try{playerid} == 3){
    SendClientMessage(playerid,-1,"Du hast 3mal dein Passwort falsch eingegben!");
    return Kick(playerid);
    }
    }
    }else return Kick(playerid);
    }
    }
    return 1;
    }


    public OnPlayerClickPlayer(playerid, clickedplayerid, source)
    {
    return 1;
    }
    public OnPlayerCheckAccount(playerid)
    {
    new row, field;
    cache_get_data(row,field);
    if(!row)return ShowPlayerDialog(playerid, DIALOG_REGISTER_ACCEPT, DIALOG_STYLE_MSGBOX,"Registrierung",DIALOG_REGISTER_ACCEPT_TEXT,"Weiter","Abbrechen");
    else{
    cache_get_field_content(0,"Password",PlayerInfo[playerid][pPassword]);
    cache_get_field_content(0,"LastLogin",PlayerInfo[playerid][pLastLogin]);
    cache_get_field_content(0,"Ban",PlayerInfo[playerid][pBan]);
    if(PlayerInfo[playerid][pBan] == 1)return Kick(playerid);
    strdel(Query,0,STR_LEN);
    strdel(ALLSTRING,0,sizeof(ALLSTRING));
    format(ALLSTRING,64,"Passworteingabe | Letzer Login: {FF8C00}%s",PlayerInfo[playerid][pLastLogin]);
    SendClientMessage(playerid,-1,"Dein Account wurde gefunden. Bitte logge dich ein.");
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login",ALLSTRING,"Anmelden","Abbrechen");
    }
    return 1;
    }
    public OnPlayerLoadPlayerData(playerid)
    {
    new data[30];
    cache_get_row(0,0,PlayerInfo[playerid][pName]);
    cache_get_row(0,2,data); PlayerInfo[playerid][pAge] = strval(data);
    cache_get_row(0,3,PlayerInfo[playerid][pCountry]);
    cache_get_row(0,4,data); PlayerInfo[playerid][pLevel] = strval(data);
    cache_get_row(0,5,data); PlayerInfo[playerid][pAdmin] = strval(data);
    cache_get_row(0,6,data); PlayerInfo[playerid][pDonate] = strval(data);
    cache_get_row(0,7,PlayerInfo[playerid][pGender]);
    cache_get_row(0,8,data); PlayerInfo[playerid][pMoney] = strval(data);
    cache_get_row(0,9,data); PlayerInfo[playerid][pBank] = strval(data);
    cache_get_row(0,10,data); PlayerInfo[playerid][pPosX] = floatstr(data);
    cache_get_row(0,11,data); PlayerInfo[playerid][pPosY] = floatstr(data);
    cache_get_row(0,12,data); PlayerInfo[playerid][pPosZ] = floatstr(data);
    cache_get_row(0,13,data); PlayerInfo[playerid][pVW] = strval(data);
    cache_get_row(0,14,data); PlayerInfo[playerid][pInt] = strval(data);
    cache_get_row(0,15,data); PlayerInfo[playerid][pFraction] = strval(data);
    cache_get_row(0,16,data); PlayerInfo[playerid][pCarlic] = strval(data);
    cache_get_row(0,17,data); PlayerInfo[playerid][pBikelic] = strval(data);
    cache_get_row(0,18,data); PlayerInfo[playerid][pPlanelic] = strval(data);
    cache_get_row(0,19,data); PlayerInfo[playerid][pLKWlic] = strval(data);
    cache_get_row(0,20,data); PlayerInfo[playerid][pHelilic] = strval(data);
    cache_get_row(0,21,data); PlayerInfo[playerid][pHealth] = floatstr(data);
    cache_get_row(0,22,data); PlayerInfo[playerid][pArmour] = floatstr(data);
    cache_get_row(0,25,PlayerInfo[playerid][pRegdate]);
    TogglePlayerSpectating(playerid,0);
    SetPlayerScore(playerid,PlayerInfo[playerid][pLevel]);
    GivePlayerMoney(playerid,PlayerInfo[playerid][pMoney]);
    SetCameraBehindPlayer(playerid);
    SetSpawnInfo(playerid, 0, 0, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], 0.0, 0, 0, 0, 0, 0, 0);
    SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][pVW]);
    SetPlayerInterior(playerid,PlayerInfo[playerid][pInt]);
    player_loged_in{playerid}=true;
    strdel(Query,0,STR_LEN);
    mysql_format(m_connect,Query,"UPDATE `accounts` SET `LastLogin` = NOW() WHERE `Name` = '%s'",PlayerName(playerid));
    mysql_function_query(m_connect,Query,false,"","");
    return SpawnPlayer(playerid);
    }
    public OnQueryError( errorid, error[], callback[], query[], connectionHandle ){
    printf("EID: %d | Error: %s | callback: %s | Query: %s", errorid, error, callback, query);
    return 1;
    }
    stock Databaseconnect()
    {
    if(mysql_ping(m_connect) == 1)return print("Verbindung hergestellt");
    else{
    m_connect = mysql_connect("localhost", "root", "samp_db", "");
    if(mysql_ping(m_connect) == 1)return print("Verbindung hergestellt");
    else{
    print("Verbindung fehlgeschlagen");
    SendRconCommand("exit");
    return 1;
    }
    }
    }
    stock SavePlayerData(playerid)
    {
    strdel(Query,0,STR_LEN);
    GetPlayerPos(playerid,PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
    PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
    PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
    mysql_format(m_connect,Query,"UPDATE `accounts` SET `Name` = '%s', `Level` = '%d', `Admin` = '%d', `Donate` = '%d', `Money` = '%d', `Bank` = '%d', `X` = '%f', `Y` = '%f', `Z` = '%f', `VW` = '%d', `Interior` = '%d', `Fraction` = '%d', `Carlic` = '%d', `Bikelic` = '%d', `Planelic` = '%d', `LKWlic` = '%d', `Helilic` = '%d', `Health` = '%f', `Armour` = '%f', `Ban` = '%d' WHERE `Name` = '%s' ",PlayerName(playerid),PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pDonate],
    PlayerInfo[playerid][pMoney],PlayerInfo[playerid][pBank],PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ],PlayerInfo[playerid][pVW],PlayerInfo[playerid][pInt],PlayerInfo[playerid][pFraction],PlayerInfo[playerid][pCarlic],PlayerInfo[playerid][pBikelic],PlayerInfo[playerid][pPlanelic],PlayerInfo[playerid][pLKWlic],PlayerInfo[playerid][pHelilic],PlayerInfo[playerid][pHealth],PlayerInfo[playerid][pArmour],PlayerInfo[playerid][pBan],PlayerInfo[playerid][pName]);
    mysql_function_query(m_connect,Query,true,"","");
    printf("%d",strlen(Query));
    return 1;
    }
    stock CreateTables()
    {
    mysql_format(m_connect,Query,"CREATE TABLE IF NOT EXISTS `accounts`(`Name` varchar(20) NOT NULL,`Password` varchar(129) NOT NULL,`Age` int(3) NOT NULL,`Country` varchar(20) NOT NULL,`Level` int(10) NOT NULL,`Admin` int(10) NOT NULL,`Donate` int(2) NOT NULL,`Gender` varchar(10) NOT NULL,`Money` int(22) NOT NULL,`Bank` int(22) NOT NULL,`X` float NOT NULL,`Y` float NOT NULL,`Z` float NOT NULL,");
    mysql_format(m_connect,Query,"%s`VW` int(6) NOT NULL,`Interior` int(3) NOT NULL,`Rank` int(2) NOT NULL,`Fraction` int(2) NOT NULL,`Carlic` int(1) NOT NULL,`Bikelic` int(1) NOT NULL,`Planelic` int(1) NOT NULL,`LKWlic` int(1) NOT NULL,`Helilic` int(1) NOT NULL,`Health` float NOT NULL,`Armour` float NOT NULL,`Ban` int(1) NOT NULL,`RegDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',`LastLogin` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00')",Query);
    mysql_function_query(m_connect,Query,false,"","");
    return 1;
    }


    unterschied hier sind paar erweiterungen , spart memory und die Accounts werden gespeichert beim Serverausfall dennoch mit dem arbeiten der variabeln also ohne auslesen sollte er auch den rest bei restarts speichern was er auch tut nur halt eben paar andere elemente, Daher kann man auch ein Timer machen der
    die variabeln erneuert verknüpfbar mit einem anticheat

    Einmal editiert, zuletzt von IPrototypeI ()

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen
  • Dan mach halt die Augen auf und schau dir die stock-funktion an .
    dennoch solltest du die Tabelle einmal erstellen lassen per skript danach die funktion ausklammern grund ist eine mir nicht bekannte komplikationen, was
    einen crash verursacht mit dem Timer. Kann jedoch auch nur bei mir sein aufgrund eines mysteriösen problems. Zu dem verwende die neuste version da
    dort der memory leak gefixxt ist.