Jump to content
  • 0

Bug sistem war


TheGodfather

Question

Salut, la gamemode-ul bhood hpq123 am observat ca dupa ce dau restart, turfurile se pun aiurea in /turfs. Cu siguranta mai sunt si alte probleme la sistemul de war. Aveti idee cum pot rezolva? Las mai jos ce tine de sistemul de war.

YCMD:turfs(playerid, params[], help) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Wait %d seconds.", aspam[playerid]);
    if(TurfsDisp[playerid] == 0) {
        TurfsDisp[playerid] = 1;
        for(new i = 0; i < sizeof(Turfs); i++) 
        {
            switch(TurfInfo[i][zOwned]) {
                case 0: GangZoneShowForPlayerEx(playerid, Turfs[i], 0xFFFFFFAA); //None
                case 4: GangZoneShowForPlayerEx(playerid, Turfs[i], 0x0CAB3C99); //Grove Street
                case 5: GangZoneShowForPlayerEx(playerid, Turfs[i], 0x11F2F299); //Los Vagos
                case 6: GangZoneShowForPlayerEx(playerid, Turfs[i], 0x8E541099); //Ballas
                case 10: GangZoneShowForPlayerEx(playerid, Turfs[i], 0xAB00FA99); //Los Aztecas
            }
        }
        SCM(playerid, -1, "You activated the turfs.");
    } else {
        TurfsDisp[playerid] = 0;
        for(new i = 0; i < sizeof(Turfs); i++) GangZoneHideForPlayerEx(playerid, Turfs[i]);
        SCM(playerid, -1, "You deactivated the turfs.");
    }
    return true;
}

function SQL_loadTurfs() {
    printf("Turfs: %d", cache_num_rows());    
    if(cache_num_rows() == 0)
        return true;

    new ORM:ormid;
     for(new i = 0; i < cache_num_rows(); i++) {
         ormid = orm_create("turfs");
         orm_addvar_int(ormid, TurfInfo[i][zID], "ID");
         orm_addvar_int(ormid, TurfInfo[i][zOwned], "Owned");
         orm_addvar_float(ormid, TurfInfo[i][zMinX], "MinX");
         orm_addvar_float(ormid, TurfInfo[i][zMinY], "MinY");
         orm_addvar_float(ormid, TurfInfo[i][zMaxX], "MaxX");
         orm_addvar_float(ormid, TurfInfo[i][zMaxY], "MaxY");

         orm_apply_cache(ormid, i);    
    }    
    for(new i = 0; i < sizeof(TurfInfo); i++) Turfs[i] = GangZoneCreateEx(TurfInfo[i][zMinX],TurfInfo[i][zMinY],TurfInfo[i][zMaxX],TurfInfo[i][zMaxY],TurfInfo[i][zID],1.0);
    return true;
}

Functia SQL_loadTurfs este folosita la OnGamemodeInit astfel: mysql_tquery(SQL, "SELECT * FROM `turfs`", "SQL_loadTurfs", "");

function OtherTimer() {
    new stringg[180], iswar;
    for(new w = 0; w < 16; w++) if(InWar[w] == 1) iswar = 1;

    if(iswar != 1)
        return true;

    for(new i = 0; i < sizeof(Turfs); i++) {
        new attackers = WarInfo[i][wAttacker];
        new defenders = WarInfo[i][wFaction];
        if(WarInfo[i][wTime] >= 2) {
            foreach(Player,j) {
                if(PlayerInfo[j][pMember] == attackers || PlayerInfo[j][pMember] == defenders) {
                    if(WarInfo[i][wAttacker] == 4) GangZoneFlashForPlayer(j,Turfs[i], 0x0CAB3C99);
                    else if(WarInfo[i][wAttacker] == 5) GangZoneFlashForPlayer(j,Turfs[i], 0x11F2F299);
                    else if(WarInfo[i][wAttacker] == 6) GangZoneFlashForPlayer(j,Turfs[i], 0x8E541099);
                    else if(WarInfo[i][wAttacker] == 10) GangZoneFlashForPlayer(j,Turfs[i], 0xAB00FA99);
                }
            }
        }
        if(WarInfo[i][wTime] > 0) {
            WarInfo[i][wTime] -= 1;
            foreach(Player,j) {
                if(IsPlayerInTurf(j,i) == 1) {
                    if(PlayerInfo[j][pMember] == attackers) WarScoreF[attackers][i] += 0.002;
                    if(PlayerInfo[j][pMember] == defenders) WarScoreF[defenders][i] += 0.002;
                }
            }
            if(WarInfo[i][wTime] == 1) {
                new Float: atscore = 0.0;
                new Float: defscore = 0.0;
                atscore = WarScoreF[attackers][i];
                defscore = WarScoreF[defenders][i];
                new winner;
                SetVehicle(attackers, 0);
                SetVehicle(defenders, 0);
                foreach(Player,j) {
                    if(PlayerInfo[j][pMember] == attackers) {
                        SCM(j, COLOR_MONEY, "--------------------- WAR Statistics ---------------------");
                        RespawnVehicle(attackers);
                        GangZoneStopFlashForPlayer(j,Turfs[i]);
                        format(stringg,sizeof(stringg),"War between %s and %s for turf %d is over.",FactionName(attackers),FactionName(defenders),i+1);
                        SCM(j, COLOR_MONEY,stringg);
                        //for(new m = 0; m < 5; m++) SendDeathMessageToPlayer(j, 1001, 1001, 200);
                        PlayerTextDrawHide(j, WarTime);
                    }
                    if(PlayerInfo[j][pMember] == defenders) {
                        SCM(j, COLOR_MONEY, "--------------------- WAR Statistics ---------------------");
                        RespawnVehicle(defenders);
                        GangZoneStopFlashForPlayer(j,Turfs[i]);
                        format(stringg,sizeof(stringg),"War between %s and %s for turf %d is over.",FactionName(attackers),FactionName(defenders),i);
                        SCM(j, COLOR_MONEY,stringg);
                        //for(new m = 0; m < 5; m++) SendDeathMessageToPlayer(j, 1001, 1001, 200);
                        PlayerTextDrawHide(j, WarTime);
                    }
                }
                DestroyPickups(i);
                if(atscore > defscore) winner = 1;
                else winner = 2;
                new winbest, losebest;
                new winbestj = -1, losebestj = -1;
                new bestname1[25],bestname2[25],bestname[25],worstname[25];
                FactionDeelay[attackers] = 300;
                foreach(Player,j) {
                    if(winner == 1) {
                        if(PlayerInfo[j][pMember] == attackers) {
                            winbest = bestscoreat[i];
                            if(bestmemberat[i] != 999) {
                                if(PlayerInfo[bestmemberat[i]][pMember] == attackers) {
                                    winbestj = bestmemberat[i];
                                    GetPlayerName(winbestj,bestname1,sizeof(bestname1));
                                    strmid(bestname, bestname1, 0, strlen(bestname1), 255);
                                }
                            }
                            else {
                                format(bestname,sizeof(bestname),"Null");
                                strmid(bestname, bestname, 0, strlen(bestname), 255);
                            }
                        }
                        if(PlayerInfo[j][pMember] == defenders) {
                            losebest = worstscoredf[i];
                            if(worstmemberdf[i] != 999) {
                                if(PlayerInfo[worstmemberdf[i]][pMember] == defenders) {
                                    losebestj = worstmemberdf[i];
                                    GetPlayerName(losebestj,bestname2,sizeof(bestname2));
                                    strmid(worstname, bestname2, 0, strlen(bestname2), 255);
                                }
                            }
                            else {
                                format(worstname,sizeof(worstname),"Null");
                                strmid(worstname, worstname, 0, strlen(worstname), 255);
                            }
                        }
                    }
                    if(winner == 2) {
                        if(PlayerInfo[j][pMember] == defenders) {
                            winbest = bestscoredf[i];
                            if(bestmemberdf[i] != 999) {
                                if(PlayerInfo[bestmemberdf[i]][pMember] == defenders) {
                                    winbestj = bestmemberdf[i];
                                    GetPlayerName(winbestj,bestname1,sizeof(bestname1));
                                    strmid(bestname, bestname1, 0, strlen(bestname1), 255);
                                }
                            }
                            else {
                                format(bestname,sizeof(bestname),"Null");
                                strmid(bestname, bestname, 0, strlen(bestname), 255);
                            }
                        }
                        if(PlayerInfo[j][pMember] == attackers) {
                            losebest = worstscoreat[i];
                            if(worstmemberat[i] != 999) {
                                if(PlayerInfo[worstmemberat[i]][pMember] == attackers) {
                                    losebestj = worstmemberat[i];
                                    GetPlayerName(losebestj,bestname2,sizeof(bestname2));
                                    strmid(worstname, bestname2, 0, strlen(bestname2), 255);
                                }
                            }
                            else {
                                format(worstname,sizeof(worstname),"Null");
                                strmid(worstname, worstname, 0, strlen(worstname), 255);
                            }
                        }
                    }
                }
                foreach(Player,j) {
                    new uciderii = 0;
                    uciderii += ucideri[j][i];
                    new decesee = 0;
                    decesee += decese[j][i];
                    ucideri[j][i] = 0;
                    decese[j][i] = 0;
                    
                    if((PlayerInfo[j][pMember] == attackers) || (PlayerInfo[j][pMember] == defenders)) {
                        SetPlayerVirtualWorld(j, 0);
                        if(WarSeconds[j] >= 300) {
                            //UpdateFactionRaport(j, 0);
                            //edisonraport
                            AddRaportPoint(j);
                            //edisonraport
                        }
                        WarSeconds[j] = 0;
                        if(winner == 1) {                    
                            format(stringg,sizeof(stringg),"%s (%.1f) vs %s (%.1f).",FactionName(WarInfo[i][wAttacker]),atscore,FactionName(WarInfo[i][wFaction]),defscore);
                            SCM(j, COLOR_MONEY,stringg);
                            format(stringg,sizeof(stringg),"The best: %s (%d). The worst: %s (-%d).", bestname, winbest, worstname, losebest);
                            SCM(j, COLOR_MONEY,stringg);
                            format(stringg,sizeof(stringg),"Your statistics: Score %d (%d kills and %d deaths).",uciderii-decesee, uciderii, decesee);
                            SCM(j, COLOR_MONEY,stringg);
                            TurfInfo[i][zOwned] = WarInfo[i][wAttacker];
                            Wartimeon[j] = 0;
                        }
                        if(winner == 2) {
                            format(stringg,sizeof(stringg),"%s (%.1f) vs %s (%.1f).",FactionName(WarInfo[i][wFaction]),defscore,FactionName(WarInfo[i][wAttacker]),atscore);
                            SCM(j, COLOR_MONEY,stringg);
                            format(stringg,sizeof(stringg),"The best: %s (%d). The worst: %s (-%d).", bestname, winbest, worstname, losebest);
                            SCM(j, COLOR_MONEY,stringg);
                            format(stringg,sizeof(stringg),"Your statistics: Score %d (%d kills and %d deaths).",uciderii-decesee,uciderii, decesee);
                            SCM(j, COLOR_MONEY,stringg);
                            Wartimeon[j] = 0;
                        }
                        SCM(j, COLOR_MONEY, "---------------------------------------------------------------");
                        WarScoreF[defenders][i] = 0.0;
                        WarScoreF[attackers][i] = 0.0;
                        InWar[attackers] = 0;
                        InWar[defenders] = 0;
                    }
                    if(winner == 1) {
                        GangZoneHideForPlayerEx(j,Turfs[i]);
                        if(attackers == 4) GangZoneShowForPlayerEx(j,Turfs[i],0x0CAB3C99);
                        if(attackers == 5) GangZoneShowForPlayerEx(j,Turfs[i],0x11F2F299);
                        if(attackers == 6) GangZoneShowForPlayerEx(j,Turfs[i],0x8E541099);
                        if(attackers == 10) GangZoneShowForPlayerEx(j,Turfs[i],0xAB00FA99);
                    }
                }
                if(winner == 1) {
                    new str[128];
                    mysql_format(SQL, str,128,"UPDATE `turfs` SET `Owned`='%d' WHERE `ID`='%d'",TurfInfo[i][zOwned],i);
                    mysql_tquery(SQL,str, "", "");
                }
                WarInfo[i][wTime] = 0;
                WarInfo[i][wFaction] = 0;
                WarInfo[i][wAttacker] = 0;
                worstscoreat[i] = 0;
                worstmemberat[i] = 999;
                bestscoreat[i] = 0;
                bestmemberat[i] = 999;
                worstscoredf[i] = 0;
                worstmemberdf[i] = 999;
                bestscoredf[i] = 0;
                bestmemberdf[i] = 999;
                mysql_tquery(SQL, "UPDATE `users` SET `WarTurf`='0', `WarKills`='0', `WarDeaths`='0'", "", "");
            }
        }
    }
    return true;
}

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Am reusit sa rezolv partea cu /turfs. Dar acum masinile nu se spawneaza corect masinile in virtual world, de exemplu daca trebuie sa le puna in vw 3, unele le duce dar unele le lasa in vw 0.

function SetVehicle(fid, turf) {
    for(new i = 1; i < MAX_SVEHICLES; i++) {
        if(ServerVehicles[i][vFaction] == fid) SetVehicleVirtualWorld(i, turf);
    }                    
    return true;
}

Link to comment
Share on other sites

  • 0

Nu înțeleg de ce funcția ta ia în funcție de sizeof(Trufs), or să apară probleme dacă în baza de date sunt mai puține, multe or să se creeze o coordonată invalidă.

Ești sigur că mașinile tale de facțiune sunt stocate în ServerVehicles?

Sigur mașinile ajung în vw 0? Verifică cum se apelează setvehicle la comanda /attack, de fapt, dă-ne și comanda attack.

Link to comment
Share on other sites

  • 0
3 hours ago, Gabi21 said:

Nu înțeleg de ce funcția ta ia în funcție de sizeof(Trufs), or să apară probleme dacă în baza de date sunt mai puține, multe or să se creeze o coordonată invalidă.

Ești sigur că mașinile tale de facțiune sunt stocate în ServerVehicles?

Sigur mașinile ajung în vw 0? Verifică cum se apelează setvehicle la comanda /attack, de fapt, dă-ne și comanda attack.

Da, acolo sunt stocate. Da, ajung in vw 0 pentru ca ma duceam in vw 0 si vedeam majoritatea masinilor de la factiune acolo, cand ele trebuiau sa fie in vw 3. Doar 4-5 masini din vreo 14 erau in vw 3, restul 0.

YCMD:attack(playerid, params[], help) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Wait %d seconds.", aspam[playerid]);
    if(!IsAMember(playerid)) return SCM(playerid,COLOR_GREY, "You are not part of a mafia.");
    if(PlayerInfo[playerid][pRank] < 7) return SCM(playerid,COLOR_LIGHTBLUE,"You do not have rank 7.");
    new turf,string[100];
    for(new i = 0; i < sizeof(TurfInfo); i++) {
        if(IsPlayerInTurf(playerid, i) == 1) {
            turf = i;
            break;
        }
    }
    new hour,minutes,second, year, month, day;
    gettime(hour,minutes,second);
    getdate(year, month, day);
    new days[180];
    format(days, sizeof(days), GetWeekDay(day, month, year));
    if(PlayerInfo[playerid][pAdmin] < 😎 {
    if(GetFactionMembersOn2(PlayerInfo[playerid][pMember]) < 2) return SCM(playerid, COLOR_LGREEN, "You can not use this command because there are less than 3 members connected from your faction!");
    if(GetFactionMembersOn2(TurfInfo[turf][zOwned]) < 2) return SCM(playerid, COLOR_LGREEN, "You can not use this command because there are less than 3 members connected from the faction owning the territory!");
    }
    if(turf == 0) return SCM(playerid, COLOR_WHITE, "You are not on a territory!");
    new faction = PlayerInfo[playerid][pMember];
    if(TurfInfo[turf][zOwned] == faction) return SCM(playerid, COLOR_GREY, "You can not attack the turf of your mafia.");
    if(WarInfo[turf][wAttacker] != 0) return SCM(playerid, COLOR_WHITE, "That turf is already attacked.");
    if(InWar[faction] == 1) return SCM(playerid, COLOR_WHITE, "There is an active war.");
    if(InWar[TurfInfo[turf][zOwned]] == 1) return SCM(playerid, COLOR_WHITE, "This mafia already has an active war.");
    if(FactionDeelay[PlayerInfo[playerid][pMember]] != 0 && PlayerInfo[playerid][pAdmin] < 😎 {
        format(string, sizeof(string), "You can use this command after %d minutes (%d seconds).", FactionDeelay[PlayerInfo[playerid][pMember]]/60, FactionDeelay[PlayerInfo[playerid][pMember]]);
        SCM(playerid, COLOR_LGREEN, string);
        return true;
    }
    format(string, sizeof(string), "[WAR] %s started a war with %s.",FactionName(PlayerInfo[playerid][pMember]), FactionName(TurfInfo[turf][zOwned]));
    SendAdminMessage(COLOR_LOGS, string, 1);
    format(string, sizeof(string), "[WAR] %s attacked territory %d owned by faction %s.",GetName(playerid),turf+1,FactionName(TurfInfo[turf][zOwned]));
    SendFactionMessage(faction,COLOR_MONEY,string);
    format(string, sizeof(string), "[WAR] %s (%s) attacked territory %d owned by faction %s.",FactionName(WarInfo[turf][wAttacker]),GetName(playerid),turf, FactionName(TurfInfo[turf][zOwned]));
    SendFactionMessage(TurfInfo[turf][zOwned],COLOR_MONEY,string);
    new query[128];
    mysql_format(SQL, query,sizeof(query),"UPDATE `turfs` SET `Time`='24' WHERE `ID`='%d'",turf);
    mysql_tquery(SQL,query, "", "");
    
    TurfInfo[turf][zTime] = 24;
    if(PlayerInfo[playerid][pAdmin] == 😎 WarInfo[turf][wTime] = 30;
    else WarInfo[turf][wTime] = 1200;
    WarInfo[turf][wAttacker] = faction;
    WarInfo[turf][wFaction] = TurfInfo[turf][zOwned];
    worstscoreat[turf] = 0;
    worstmemberat[turf] = 999;
    bestscoreat[turf] = 0;
    bestmemberat[turf] = 999;
    worstscoredf[turf] = 0;
    worstmemberdf[turf] = 999;
    bestscoredf[turf] = 0;
    bestmemberdf[turf] = 999;
    InWar[TurfInfo[turf][zOwned]] = 1;
    InWar[faction] = 1;
    
    InWarTurf[faction] = turf;
    InWarTurf[TurfInfo[turf][zOwned]] = turf;
    
    foreach(Player, i) {
        if(IsPlayerLogged[i] == 1) {
            if(PlayerInfo[i][pMember] == faction || PlayerInfo[i][pMember] == TurfInfo[turf][zOwned]) UpdateVar(i, "WarTurf", turf);
        }
    }
    
    SetVehicle(faction, turf+1);
    SetVehicle(TurfInfo[turf][zOwned], turf+1);
    return true;
}

Edited by TheGodfather
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.