Gangs speichern nicht

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
  • Abend


    bei mir wollen die Gangs einfach nicht speichern.Sobald ich den Server restarte , werden alle erstellten Gangs wieder gelöscht.


    Hoffentlich kann mir einer von euch helfen


    #include <a_samp>
    #include <core>
    #include <float>


    #pragma tabsize 0


    #define COLOR_GREY 0xAFAFAFAA
    #define COLOR_GREEN 0x33AA33AA
    #define COLOR_RED 0xAA3333AA
    #define COLOR_YELLOW 0xFFFF00AA
    #define COLOR_WHITE 0xFFFFFFAA
    #define COLOR_BLUE 0x0000BBAA
    #define COLOR_LIGHTBLUE 0x33CCFFAA
    #define COLOR_ORANGE 0xFF9900AA


    #define NUMVALUES 4


    #define CP_BANK 0
    #define CP_PIRATE 1
    #define CP_SKYSCARPER 2
    #define CP_ZOMBOTECH 3
    #define CP_AMMU 4
    #define CP_AMMU_2 5
    #define CP_BANK_2 6
    #define CP_BANK_3 7
    #define CP_LS_AIR 8
    #define CP_SF_AIR 9
    #define CP_LV_AIR 10
    #define CP_ALAHAM 11
    #define CP_DIDERSACHS 12
    #define CP_BAR 13
    #define CP_HAIRSTUD 14
    #define CP_ZIP 15
    #define CP_BINCO 16
    #define CP_TATOO 17
    #define CP_GOLF 18
    #define CP_WANG 19
    #define CP_HOTEL 20
    #define CP_OTTOS 21
    #define CP_DRAGON 22
    #define CP_CALIGULA 23
    #define CP_SEXSHOP 24
    #define CP_CATHAY 25
    #define CP_VERONA 26
    #define CP_ZERORC 27
    #define CP_JIZZYS 28
    #define CP_PIRAMID 29


    #define P_ALAHAM 0
    #define P_DIDERSACHS 1
    #define P_BAR 2
    #define P_HAIRSTUD 3
    #define P_ZIP 4
    #define P_BINCO 5
    #define P_TATOO 6
    #define P_GOLF 7
    #define P_WANG 8
    #define P_HOTEL 9
    #define P_OTTOS 10
    #define P_DRAGON 11
    #define P_CALIGULA 12
    #define P_SEXSHOP 13
    #define P_CATHAY 14
    #define P_VERONA 15
    #define P_ZERORC 16
    #define P_JIZZYS 17
    #define P_PIRAMID 18


    #define P_OFFSET 11



    forward PlayerLeaveGang(playerid);
    forward PirateShipScoreUpdate();
    forward GambleUpdate();
    forward checkpointUpdate();
    forward PropertyScoreUpdate();
    forward SendPlayerFormattedText(playerid, const str[], define);
    forward SendAllFormattedText(playerid, const str[], define);


    forward Givecashdelaytimer(playerid);
    new bank[MAX_PLAYERS];




    new playerColors[103] = {
    0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,0xF4A460FF,0xEE82EEFF,0xFFD720FF,
    0x8b4513FF,0x4949A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34DAFF,
    0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,0x65ADEBFF,0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF,
    0x275222FF,0xF09F5BFF,0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF,
    0x057F94FF,0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,0x4B8987FF,
    0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,0x12D6D4FF,0x48C000FF,0x2A51E2FF,0xE3AC12FF,
    0xFC42A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7ECFF,
    0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF,
    0x9F945CFF,0xDCDE3DFF,0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,0xD8C762FF,
    0x3FE65CFF,0x33CCFFAA,0xFF66FFAA,0xFF0000AA
    };





    #define MAX_CASINO 3



    #define MAX_GANGS 32
    #define MAX_GANG_MEMBERS 6
    #define MAX_GANG_NAME 16
    new gangMembers[MAX_GANGS][MAX_GANG_MEMBERS];
    new gangNames[MAX_GANGS][MAX_GANG_NAME];
    new gangInfo[MAX_GANGS][3]; //0-created,1-members,2-color
    new gangBank[MAX_GANGS];
    new playerGang[MAX_PLAYERS];
    new gangInvite[MAX_PLAYERS];


    public PlayerLeaveGang(playerid) {
    new string[256];
    new playername[MAX_PLAYER_NAME];
    new gangnum = playerGang[playerid];


    if(gangnum > 0) {
    for(new i = 0; i < gangInfo[gangnum][1]; i++) {
    if(gangMembers[gangnum][i]==playerid) {


    //One less gang member
    gangInfo[gangnum][1]--;


    for(new j = i; j < gangInfo[gangnum][1]; j++) {
    //Shift gang members
    gangMembers[gangnum][j]=gangMembers[gangnum][j+1];
    }


    //Disband gang if no more members
    if(gangInfo[gangnum][1]<1) {
    gangInfo[gangnum][0]=0;
    gangInfo[gangnum][1]=0;
    gangBank[gangnum]=0;
    }


    //Notify other members
    for(new j = 0; j < gangInfo[gangnum][1]; j++) {
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string),"%s has destroy your gang.", playername);
    SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
    }


    format(string, sizeof(string),"You have destroy the gang '%s' (id: %d)", gangNames[gangnum], gangnum);
    SendClientMessage(playerid, COLOR_ORANGE, string);


    playerGang[playerid]=0;


    SetPlayerColor(playerid,playerColors[playerid]);


    return;
    }
    }
    } else {
    SendClientMessage(playerid, COLOR_RED, "You are not in a gang.");
    }
    }


    //------------------------------------------------------------------------------------------------------



    //------------------------------------------------------------------------------------------------------



    //------------------------------------------------------------------------------------------------------


    //------------------------------------------------------------------------------------------------------


    //------------------------------------------------------------------------------------------------------


    public OnPlayerCommandText(playerid, cmdtext[])
    {
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[256];
    new giveplayerid, moneys, idx;


    cmd = strtok(cmdtext, idx);


    if(strcmp(cmd, "/bank", true) == 0 || strcmp(cmd, "/gbank", true) == 0) {
    new gang;
    if(strcmp(cmd, "/gbank", true) == 0)
    gang = 1;
    if(gang && playerGang[playerid]==0) {
    SendClientMessage(playerid, COLOR_RED, "You are not in a gang!");
    return 1;
    }


    new tmp[256];
    tmp = strtok(cmdtext, idx);


    if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /(g)bank [amount]");
    return 1;
    }
    moneys = strval(tmp);


    if(moneys < 1) {
    SendClientMessage(playerid, COLOR_YELLOW, "Hey what are you trying to pull here.");
    return 1;
    }


    if(GetPlayerMoney(playerid) < moneys) {
    moneys = GetPlayerMoney(playerid);
    }


    GivePlayerMoney(playerid, 0-moneys);


    if(gang)
    gangBank[playerGang[playerid]]+=moneys;
    else
    bank[playerid]+=moneys;


    if(gang)
    format(string, sizeof(string), "You have deposited $%d, your gang's balance is $%d.", moneys, gangBank[playerGang[playerid]]);
    else
    format(string, sizeof(string), "You have deposited $%d, your current balance is $%d.", moneys, bank[playerid]);


    SendClientMessage(playerid, COLOR_YELLOW, string);


    return 1;
    }


    //------------------- /withdraw


    if(strcmp(cmd, "/withdraw", true) == 0 || strcmp(cmd, "/gwithdraw", true) == 0) {
    new gang;
    if(strcmp(cmd, "/gwithdraw", true) == 0)
    gang = 1;


    if(gang && playerGang[playerid]==0) {
    SendClientMessage(playerid, COLOR_RED, "You are not in a gang!");
    return 1;
    }


    new tmp[256];
    tmp = strtok(cmdtext, idx);


    if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /(g)withdraw [amount]");
    return 1;
    }
    moneys = strval(tmp);


    if(moneys < 1) {
    SendClientMessage(playerid, COLOR_YELLOW, "Hey what are you trying to pull here.");
    return 1;
    }


    if(gang) {
    if(moneys > gangBank[playerGang[playerid]])
    moneys = gangBank[playerGang[playerid]];
    } else {
    if(moneys > bank[playerid])
    moneys = bank[playerid];
    }


    GivePlayerMoney(playerid, moneys);
    if(gang)
    gangBank[playerGang[playerid]] -= moneys;
    else
    bank[playerid] -= moneys;


    if(gang)
    format(string, sizeof(string), "You have withdrawn $%d, your gang's balance is $%d.", moneys, gangBank[playerGang[playerid]]);
    else
    format(string, sizeof(string), "You have withdrawn $%d, your current balance is $%d.", moneys, bank[playerid]);
    SendClientMessage(playerid, COLOR_YELLOW, string);


    return 1;
    }
    if(strcmp(cmd, "/gang", true) == 0) {
    new tmp[256];
    new gangcmd, gangnum;
    tmp = strtok(cmdtext, idx);


    if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gang [create/join/invite/destroy] [name/number]");
    return 1;
    }
    giveplayerid = strval(tmp);


    if(strcmp(tmp, "create", true)==0)
    gangcmd = 1;
    else if(strcmp(tmp, "invite", true)==0)
    gangcmd = 2;
    else if(strcmp(tmp, "join", true)==0)
    gangcmd = 3;
    else if(strcmp(tmp, "destroy", true)==0)
    gangcmd = 4;


    tmp = strtok(cmdtext, idx);
    if(gangcmd < 3 && !strlen(tmp)) {
    if(gangcmd==0)
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gang [create/join/invite/destroy] [name/number]");
    else if(gangcmd==1)
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gang [create] [name]");
    else if(gangcmd==2)
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gang [invite] [playerID]");
    return 1;
    }


    //Create Gang//
    if(gangcmd==1) {
    if(playerGang[playerid]>0) {
    SendClientMessage(playerid, COLOR_RED, "You are already in a gang!");
    return 1;
    }


    for(new i = 1; i < MAX_GANGS; i++) {
    if(gangInfo[i][0]==0) {
    //name gang
    format(gangNames[i], MAX_GANG_NAME, "%s", tmp);
    //Gang exists
    gangInfo[i][0]=1;
    //There is one member
    gangInfo[i][1]=1;
    //Gang color is player's color
    gangInfo[i][2]=playerColors[playerid];


    //Player is the first gang member
    gangMembers[i][0] = playerid;
    format(string, sizeof(string),"You have created the gang '%s' (id: %d)", gangNames[i], i);
    SendClientMessage(playerid, COLOR_GREEN, string);


    playerGang[playerid]=i;


    return 1;
    }
    }


    return 1;


    //Join Gang//
    } else if (gangcmd==3) {
    gangnum = gangInvite[playerid];


    if(playerGang[playerid]>0) {
    SendClientMessage(playerid, COLOR_RED, "You are already in a gang!");
    return 1;
    }
    if(gangInvite[playerid]==0) {
    SendClientMessage(playerid, COLOR_RED, "You have not been invited to a gang.");
    return 1;
    }
    if(gangInfo[gangnum][0]==0) {
    SendClientMessage(playerid, COLOR_RED, "That gang does not exist!");
    return 1;
    }


    if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS) {
    new i = gangInfo[gangnum][1];


    gangInvite[playerid]=0;


    gangMembers[gangnum][i] = playerid;


    GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
    for(new j = 0; j < gangInfo[gangnum][1]; j++) {
    format(string, sizeof(string),"%s has joined your gang.", sendername);
    SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
    }


    gangInfo[gangnum][1]++;
    playerGang[playerid] = gangnum;


    SetPlayerColor(playerid,gangInfo[gangnum][2]);


    format(string, sizeof(string),"You have joined the gang '%s' (id: %d)", gangNames[gangnum], gangnum);
    SendClientMessage(playerid, COLOR_GREEN, string);


    return 1;
    }


    SendClientMessage(playerid, COLOR_RED, "That gang is full.");
    return 1;


    //Invite to Gang//
    } else if (gangcmd==2) {
    giveplayerid = strval(tmp);


    if(playerGang[playerid]==0) {
    SendClientMessage(playerid, COLOR_RED, "You are not in a gang!");
    return 1;
    }
    // if(gangMembers[playerGang[playerid]][0]!=playerid) {
    // SendClientMessage(playerid, COLOR_RED, "You need to be the gang leader to send an invite.");
    // return 1;
    // }


    if(IsPlayerConnected(giveplayerid)) {
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));


    format(string, sizeof(string),"You have sent a gang invite to %s.", giveplayer);
    SendClientMessage(playerid, COLOR_GREEN, string);
    format(string, sizeof(string),"You have recieved a gang invite from %s to '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]);
    SendClientMessage(giveplayerid, COLOR_GREEN, string);


    gangInvite[giveplayerid]=playerGang[playerid];


    } else
    SendClientMessage(playerid, COLOR_RED, "No such player exists!");


    //Leave Gang//
    } else if (gangcmd==4) {
    PlayerLeaveGang(playerid);
    }


    return 1;
    }


    //------------------- /ganginfo


    if(strcmp(cmd, "/ganginfo", true) == 0) {
    new tmp[256];
    new gangnum;
    tmp = strtok(cmdtext, idx);


    if(!strlen(tmp) && playerGang[playerid]==0) {
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ganginfo [number]");
    return 1;
    } else if (!strlen(tmp))
    gangnum = playerGang[playerid];
    else
    gangnum = strval(tmp);


    if(gangInfo[gangnum][0]==0) {
    SendClientMessage(playerid, COLOR_RED, "No such gang exists!");
    return 1;
    }


    format(string, sizeof(string),"'%s' Gang Members (id: %d)", gangNames[gangnum], gangnum);
    SendClientMessage(playerid, COLOR_GREEN, string);


    for(new i = 0; i < gangInfo[gangnum][1]; i++) {
    GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer));
    format(string, sizeof(string),"%s (%d)", giveplayer, gangMembers[gangnum][i]);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    }


    return 1;
    }


    //------------------- /gangs


    if(strcmp(cmd, "/gangs", true) == 0)
    {
    new x;


    SendClientMessage(playerid, COLOR_GREEN, "Current Gangs:");
    for(new i=0; i < MAX_GANGS; i++) {
    if(gangInfo[i][0]==1) {
    format(string, sizeof(string), "%s%s(%d) - %d members", string,gangNames[i],i,gangInfo[i][1]);


    x++;
    if(x > 2) {
    SendClientMessage(playerid, COLOR_YELLOW, string);
    x = 0;
    format(string, sizeof(string), "");
    } else {
    format(string, sizeof(string), "%s, ", string);
    }
    }
    }


    if(x <= 2 && x > 0) {
    string[strlen(string)-2] = '.';
    SendClientMessage(playerid, COLOR_YELLOW, string);
    }


    return 1;
    }


    return 0;
    }
    strtok(const string[], &index)
    {
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
    index++;
    }


    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
    result[index - offset] = string[index];
    index++;
    }
    result[index - offset] = EOS;
    return result;
    }
    public OnFilterScriptExit()
    {
    return 1;
    }

  • Stimmt. Du speicherst die gangs zwar, aber nur in temporären Variablen, die nach einem Server erspart wieder weg sind.


    Du musst die gangs mittels Files oder MySQL speichern und ebenso wieder laden.
    Das ist aber kein fünf-minuten-code, da solltest etwas Zeit einplanen, nur so am Rande.

  • sollte ? das kannst du so nicht fragen
    Ich mein:
    kannst du mit mysql Scripten, hast du das jemals verwendet,etc.
    das sind so fragen die du dir stellen musst.


    Mysql ist natürlich das beste und Übersichtiger aber wenn du nur mit dini oder sscanf kannst ist das ja nicht schlimm bzw. egal

  • Hätte da nochmal kurz ne Frage :D


    Ich bin erst seit gestern dabei.Ich weiss garnicht wo ich anfangen soll.
    Welche Grundlagen muss man wissen um die "Scripter-Sprache" wenn man das so nennen darf ;) verstehen tut ?