waffen speichern/laden mysql

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 habe hier ma meinen code für waffen laden und spawn ich peronlich finde den bisel blöd und wollte wissen obs noch ne andere lösung gibt vom code her mir ist einfach nixe mehr eingefallen weiter auser diese lösung,


    laden
    public OnPlayerSpawn(playerid)
    {
    new obsql[128],resultline[64];
    new player_weapon1, player_weapon1_ammo, player_weapon2, player_weapon2_ammo, player_weapon3, player_weapon3_ammo;
    new player_weapon4, player_weapon4_ammo, player_weapon5, player_weapon5_ammo, player_weapon6, player_weapon6_ammo;
    new player_weapon7, player_weapon7_ammo, player_weapon8, player_weapon8_ammo, player_weapon9, player_weapon9_ammo;
    new player_weapon10, player_weapon10_ammo, player_weapon11, player_weapon11_ammo, player_weapon12, player_weapon12_ammo,player_weapon13, player_weapon13_ammo;
    format(obsql,sizeof(obsql),"SELECT * FROM `players` WHERE `Name`= '%s'",oGetPlayerName(playerid));
    mysql_query(obsql); mysql_store_result();
    if(mysql_fetch_row(resultline))
    {
    mysql_fetch_field("weapon1",obsql); player_weapon1 = strval(obsql);
    mysql_fetch_field("weapon1_ammo",obsql); player_weapon1_ammo = strval(obsql);
    mysql_fetch_field("weapon2",obsql); player_weapon2 = strval(obsql);
    mysql_fetch_field("weapon2_ammo",obsql); player_weapon2_ammo = strval(obsql);
    mysql_fetch_field("weapon3",obsql); player_weapon3 = strval(obsql);
    mysql_fetch_field("weapon3_ammo",obsql); player_weapon3_ammo = strval(obsql);
    mysql_fetch_field("weapon4",obsql); player_weapon4 = strval(obsql);
    mysql_fetch_field("weapon4_ammo",obsql); player_weapon4_ammo = strval(obsql);
    mysql_fetch_field("weapon5",obsql); player_weapon5 = strval(obsql);
    mysql_fetch_field("weapon5_ammo",obsql); player_weapon5_ammo = strval(obsql);
    mysql_fetch_field("weapon6",obsql); player_weapon6 = strval(obsql);
    mysql_fetch_field("weapon6_ammo",obsql); player_weapon6_ammo = strval(obsql);
    mysql_fetch_field("weapon7",obsql); player_weapon7 = strval(obsql);
    mysql_fetch_field("weapon7_ammo",obsql); player_weapon7_ammo = strval(obsql);
    mysql_fetch_field("weapon8",obsql); player_weapon8 = strval(obsql);
    mysql_fetch_field("weapon8_ammo",obsql); player_weapon8_ammo = strval(obsql);
    mysql_fetch_field("weapon9",obsql); player_weapon9 = strval(obsql);
    mysql_fetch_field("weapon9_ammo",obsql); player_weapon9_ammo = strval(obsql);
    mysql_fetch_field("weapon10",obsql); player_weapon10 = strval(obsql);
    mysql_fetch_field("weapon10_ammo",obsql); player_weapon10_ammo = strval(obsql);
    mysql_fetch_field("weapon11",obsql); player_weapon11 = strval(obsql);
    mysql_fetch_field("weapon11_ammo",obsql); player_weapon11_ammo = strval(obsql);
    mysql_fetch_field("weapon12",obsql); player_weapon12 = strval(obsql);
    mysql_fetch_field("weapon12_ammo",obsql); player_weapon12_ammo = strval(obsql);
    mysql_fetch_field("weapon13",obsql); player_weapon13 = strval(obsql);
    mysql_fetch_field("weapon13_ammo",obsql); player_weapon13_ammo = strval(obsql);
    }
    if(MySQL_Player_Exist(playerid) == 1)
    {
    GivePlayerWeapon(playerid, player_weapon1, player_weapon1_ammo);
    GivePlayerWeapon(playerid, player_weapon2, player_weapon2_ammo);
    GivePlayerWeapon(playerid, player_weapon3, player_weapon3_ammo);
    GivePlayerWeapon(playerid, player_weapon4, player_weapon4_ammo);
    GivePlayerWeapon(playerid, player_weapon5, player_weapon5_ammo);
    GivePlayerWeapon(playerid, player_weapon6, player_weapon6_ammo);
    GivePlayerWeapon(playerid, player_weapon7, player_weapon7_ammo);
    GivePlayerWeapon(playerid, player_weapon8, player_weapon8_ammo);
    GivePlayerWeapon(playerid, player_weapon9, player_weapon9_ammo);
    GivePlayerWeapon(playerid, player_weapon10, player_weapon10_ammo);
    GivePlayerWeapon(playerid, player_weapon11, player_weapon11_ammo);
    GivePlayerWeapon(playerid, player_weapon12, player_weapon12_ammo);
    GivePlayerWeapon(playerid, player_weapon13, player_weapon13_ammo);
    }
    return 1;
    }


    speichern

    stock Player_save_Data(playerid)
    {


    new waffe1,waffe2,waffe3,waffe4,waffe5,waffe6,waffe7,waffe8,waffe9,waffe10,waffe11,waffe12,waffe13;
    new ammo1,ammo2,ammo3,ammo4,ammo5,ammo6,ammo7,ammo8,ammo9,ammo10,ammo11,ammo12,ammo13;
    GetPlayerWeaponData(playerid,1,waffe1,ammo1);
    GetPlayerWeaponData(playerid,2,waffe2,ammo2);
    GetPlayerWeaponData(playerid,3,waffe3,ammo3);
    GetPlayerWeaponData(playerid,4,waffe4,ammo4);
    GetPlayerWeaponData(playerid,5,waffe5,ammo5);
    GetPlayerWeaponData(playerid,6,waffe6,ammo6);
    GetPlayerWeaponData(playerid,7,waffe7,ammo7);
    GetPlayerWeaponData(playerid,8,waffe8,ammo8);
    GetPlayerWeaponData(playerid,9,waffe9,ammo9);
    GetPlayerWeaponData(playerid,10,waffe10,ammo10);
    GetPlayerWeaponData(playerid,11,waffe11,ammo11);
    GetPlayerWeaponData(playerid,12,waffe12,ammo12);
    GetPlayerWeaponData(playerid,13,waffe13,ammo13);
    new src[MAX_STRING];
    format(query,sizeof(query),"UPDATE `"PlayerTable"` SET ");
    format(src,sizeof(src),"`weapon1`=%d,",waffe1);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon1_ammo`=%d,",ammo1);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon2`=%d,",waffe2);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon2_ammo`=%d,",ammo2);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon3`=%d,",waffe3);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon3_ammo`=%d,",ammo3);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon4`=%d,",waffe4);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon4_ammo`=%d,",ammo4);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon5`=%d,",waffe5);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon5_ammo`=%d,",ammo5);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon6`=%d,",waffe6);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon6_ammo`=%d,",ammo6);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon7`=%d,",waffe7);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon7_ammo`=%d,",ammo7);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon8`=%d,",waffe8);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon8_ammo`=%d,",ammo8);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon9`=%d,",waffe9);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon9_ammo`=%d,",ammo9);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon10`=%d,",waffe10);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon10_ammo`=%d,",ammo10);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon11`=%d,",waffe11);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon11_ammo`=%d,",ammo11);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon12`=%d,",waffe12);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon12_ammo`=%d,",ammo12);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon13`=%d,",waffe1);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src),"`weapon13_ammo`=%d",ammo13);
    strcat(query,src,sizeof(query));
    format(src,sizeof(src)," WHERE `Name`='%s'",oGetPlayerName(playerid));
    strcat(query,src,sizeof(query));
    samp_mysql_query(query);
    }