Jump to content
  • 0

GM bhood hpq123 /spray


TheGodfather

Question

Salut, cand dau /spray si sunt 2 sau mai multi playeri, apare de mai multe ori mesajul ca mai este o persoana care desenaza pe acest perete, dar ne lasa pe amandoi sa desenam, gen animatia merge. Progresul nu se pune de la amandoi, cum as putea face ca doar un jucatori sa poata da /spray?

YCMD:spray(playerid, params[], help) {
    new clanid = PlayerInfo[playerid][pClan], string[180];
    if(clanid == 0) return SCM(playerid, COLOR_GREY, "Nu faci parte dintr-un clan!");
    if(ClanDuty[playerid] == 0) return SCM(playerid,-1,"Nu esti la datorie!");
    if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, "Nu poti folosi aceasta comanda atata timp cat esti intr-un vehicul!");
    if(StartedSpray2[playerid] == 1) return true;
    if(StartedSpray[playerid] == 0) ClanProces[playerid] = 0;    
    new hour,minute,second, year, month, day;
    gettime(hour,minute,second);
    getdate(year, month, day);
    //if(hour >= 00 && hour < 😎 return SCM(playerid, -1, "Nu poti folosi aceasta comanda in intervalul 00-08.");
    for(new h = 0; h < MAX_SAFEZONES; h++) {
        if(PlayerToPoint(8, playerid, GraffitiInfo[h][gfX], GraffitiInfo[h][gfY], GraffitiInfo[h][gfZ])) {
            if(StartedSprayOn[playerid] != 0 && StartedSprayOn[playerid] != h) {} //SCM(playerid, COLOR_LGREEN, "Eroare: Nu poti desena pe acest perete!");
            else if(GraffitiInfo[h][gfOwned] == PlayerInfo[playerid][pClan]) SCM(playerid, COLOR_LGREEN, "Eroare: Acest perete este detinut de clanul tau!");
            //else if(CountWallSpray(h) == 1) SCM(playerid, COLOR_LGREEN, "Eroare: Mai este o persoana care deseneaza pe acest perete!");
            else {
                if(StartedSpray[playerid] == 0) {
                    if(GraffitiInfo[h][gfOwned] == 0) format(string, sizeof(string), "Ai inceput sa scrii pe peretele cu id-ul %d, detinut de clanul: Server", h);
                    else format(string, sizeof(string), "Ai inceput sa scrii pe peretele cu id-ul %d, detinut de clanul: %s", h, ClanInfo[GraffitiInfo[h][gfOwned]][clName]);
                    SCM(playerid, COLOR_LIGHTBLUE, string);
                    GraffitiInfo[h][gfAttacked] = clanid;
                    format(string, sizeof(string), "{%s}%s (din clanul %s) a inceput sa deseneze pe peretele clanului tau (turf id %d).", ClanInfo[GraffitiInfo[h][gfOwned]][clColor], GetName(playerid), ClanInfo[PlayerInfo[playerid][pClan]][clName], h);
                    SendClanMessage(GraffitiInfo[h][gfOwned], string);
                }
                ApplyAnimation(playerid,"SPRAYCAN","spraycan_full",4.0,0,0,0,0,0);
                PlayerPlaySound(playerid, 1134, 0.0, 0.0, 0.0);
                SetTimerEx( "FinalProces", 4000, 0, "d", playerid );
                StartedSpray[playerid] = 1;
                StartedSpray2[playerid] = 1;
                StartedSprayOn[playerid] = h;
            }
        }
    }
    return true;
}

function CountWallSpray(id) {
    foreach(Player, i) {
        if(StartedSprayOn[i] == id) return true;
    }
    return false;
}

function FinalProces(playerid) {
    if(IsPlayerConnected(playerid) && StartedSpray[playerid] == 1) {
        ClearAnimations(playerid);
        new string[180];
        new test = 7 + random(6);
        ClanProces[playerid] += test;
        if(ClanProces[playerid] >= 100) {
            new tagname[180];
            new i = StartedSprayOn[playerid];
            format(string, sizeof(string), "{%s}%s (din clanul %s) a reusit sa deseneze complet peretele (turf id %d).", ClanInfo[GraffitiInfo[i][gfOwned]][clColor], GetName(playerid), ClanInfo[PlayerInfo[playerid][pClan]][clName], i);
            SendClanMessage(GraffitiInfo[i][gfOwned], string);
            format(string, sizeof(string), "{%s}%s a reusit sa deseneze complet peretele (turf id %d).", ClanInfo[GraffitiInfo[i][gfOwned]][clColor], GetName(playerid), i);
            SendClanMessage(PlayerInfo[playerid][pClan], string);
            GraffitiInfo[i][gfOwned] = PlayerInfo[playerid][pClan];
            DestroyDynamicObject(GraffitiInfo[i][gfObject]);
            GraffitiInfo[i][gfObject] = CreateDynamicObject(19353, GraffitiInfo[i][gfX], GraffitiInfo[i][gfY], GraffitiInfo[i][gfZ], 0.0, 0.0, GraffitiInfo[i][gfRot]);
            format(tagname, sizeof(tagname), "{%s}%s\n%s", ClanInfo[GraffitiInfo[i][gfOwned]][clColor], ClanInfo[GraffitiInfo[i][gfOwned]][clName], ClanInfo[GraffitiInfo[i][gfOwned]][clTag]);
            SetDynamicObjectMaterialText(GraffitiInfo[i][gfObject], 0, tagname, OBJECT_MATERIAL_SIZE_512x256, "BankGothic Md BT", 60, 1, 0xfff0f0f0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
            
            GraffitiInfo[StartedSprayOn[playerid]][gfAttacked] = 0;
            new query[256];
            mysql_format(SQL, query, sizeof(query), "UPDATE `graffiti` SET `Owned`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pClan], i);
            mysql_tquery(SQL, query, "", "");
            StartedSpray[playerid] = 0;
            StartedSpray2[playerid] = 0;
            StartedSprayOn[playerid] = 0;
        }
        else {
            format(string, sizeof(string), "Continua sa desenezi peretele! (%d%s)", ClanProces[playerid], "%%");
            SCM(playerid, COLOR_GOLD, string);
        }
        StartedSpray2[playerid] = 0;
    }
    return true;
}

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Salutare, 

Incearca sa modifici functia ca in exemplul de mai jos

function CountWallSpray(id) 
{
    new count = 0;
    foreach(Player, i) 
    if(StartedSprayOn[i] == id) count++;    
    return count;
}

iar la verificare din comanda

   //else if(CountWallSpray(h) == 1)

inloc de == 1 modifica in > 1

 

In functia ta doar verificai daca cineva foloseste comanda, iar rezultatul era pozitiv pentru ca tu foloseai comanda, mai poti modifica functia ta adaugand un parametru de id si apoi sa il excluzi in for astfel verifici daca mai este cineva in comanda de spray inafara de tine.

Si poti face in felul urmator

if(CountWallSpray(h,playerid) == 1)

Iar la functie modifici in felul urmator

function CountWallSpray(id,playerid) {
    foreach(Player, i) {
        if(StartedSprayOn[i] == id && id != playerid) return true;
    }
    return false;
}

 

 

    __  ____      __           
   /  |/  (_)____/ /____  _____
  / /|_/ / / ___/ __/ _ \/ ___/
 / /  / / (__  ) /_/  __/ /    
/_/  /_/_/____/\__/\___/_/     
SERVICII SCRIPTING DE CALITATE
Pagina     Scripting     pawn
Link to comment
Share on other sites

  • 0
Acum 43 minute, Mister a spus:

Salutare, 

Incearca sa modifici functia ca in exemplul de mai jos


function CountWallSpray(id) 
{
    new count = 0;
    foreach(Player, i) 
    if(StartedSprayOn[i] == id) count++;    
    return count;
}

iar la verificare din comanda


   //else if(CountWallSpray(h) == 1)

inloc de == 1 modifica in > 1

 

In functia ta doar verificai daca cineva foloseste comanda, iar rezultatul era pozitiv pentru ca tu foloseai comanda, mai poti modifica functia ta adaugand un parametru de id si apoi sa il excluzi in for astfel verifici daca mai este cineva in comanda de spray inafara de tine.

Si poti face in felul urmator


if(CountWallSpray(h,playerid) == 1)

Iar la functie modifici in felul urmator


function CountWallSpray(id,playerid) {
    foreach(Player, i) {
        if(StartedSprayOn[i] == id && id != playerid) return true;
    }
    return false;
}

 

Voi incerca in seara asta, multumesc frumos pentru raspuns. O sa revin cu un raspuns sa zic daca merge.

Link to comment
Share on other sites

  • 0

La prima metoda, dupa ce cineva da spray o data, dupa nimeni nu mai poate da si primeste mesajul: mai este o persoana care desenaza pe acest perete. 

La a doua metoda, daca incep sa desenez pe un perete merge bine, dar daca merg la alt loc imi zice ca nu pot desena pe acel perete.

Link to comment
Share on other sites

  • 0

am avut eu o greseala la a doua metoda

if(StartedSprayOn[i] == id && i != playerid)

Asa ar trebui sa fie linia aceea.

Iar la prima metoda ai pus exact asa? fara else?

if(CountWallSpray(h) > 1)

 

 

    __  ____      __           
   /  |/  (_)____/ /____  _____
  / /|_/ / / ___/ __/ _ \/ ___/
 / /  / / (__  ) /_/  __/ /    
/_/  /_/_/____/\__/\___/_/     
SERVICII SCRIPTING DE CALITATE
Pagina     Scripting     pawn
Link to comment
Share on other sites

  • 0

YCMD:spray(playerid, params[], help) {
    new clanid = PlayerInfo[playerid][pClan], string[180];
    if(clanid == 0) return SCM(playerid, COLOR_GREY, "Nu faci parte dintr-un clan!");
    if(ClanDuty[playerid] == 0) return SCM(playerid,-1,"Nu esti la datorie!");
    if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, "Nu poti folosi aceasta comanda atata timp cat esti intr-un vehicul!");
    if(StartedSpray2[playerid] == 1) return true;
    if(StartedSpray[playerid] == 0) ClanProces[playerid] = 0;    
    new hour,minute,second, year, month, day;
    gettime(hour,minute,second);
    getdate(year, month, day);
    //if(hour >= 00 && hour < 😎 return SCM(playerid, -1, "Nu poti folosi aceasta comanda in intervalul 00-08.");
    for(new h = 0; h < MAX_SAFEZONES; h++) {
        if(PlayerToPoint(8, playerid, GraffitiInfo[h][gfX], GraffitiInfo[h][gfY], GraffitiInfo[h][gfZ])) {
            if(StartedSprayOn[playerid] != 0 && StartedSprayOn[playerid] != h) /*{}*/ SCM(playerid, COLOR_LGREEN, "Eroare: Nu poti desena pe acest perete!");
            else 
            if(GraffitiInfo[h][gfOwned] == PlayerInfo[playerid][pClan]) SCM(playerid, COLOR_LGREEN, "Eroare: Acest perete este detinut de clanul tau!");
            /*else*/ 
            if(CountWallSpray(h,playerid) == 1) SCM(playerid, COLOR_LGREEN, "Eroare: Mai este o persoana care deseneaza pe acest perete!");
            else {
                if(StartedSpray[playerid] == 0) {
                    if(GraffitiInfo[h][gfOwned] == 0) format(string, sizeof(string), "Ai inceput sa scrii pe peretele cu id-ul %d, detinut de clanul: Server.", h);
                    else format(string, sizeof(string), "Ai inceput sa scrii pe peretele cu id-ul %d, detinut de clanul: %s", h, ClanInfo[GraffitiInfo[h][gfOwned]][clName]);
                    SCM(playerid, COLOR_LIGHTBLUE, string);
                    GraffitiInfo[h][gfAttacked] = clanid;
                    format(string, sizeof(string), "{%s}%s (din clanul %s) a inceput sa deseneze pe peretele clanului tau (turf id %d).", ClanInfo[GraffitiInfo[h][gfOwned]][clColor], GetName(playerid), ClanInfo[PlayerInfo[playerid][pClan]][clName], h);
                    SendClanMessage(GraffitiInfo[h][gfOwned], string);
                }
                ApplyAnimation(playerid,"SPRAYCAN","spraycan_full",4.0,0,0,0,0,0);
                PlayerPlaySound(playerid, 1134, 0.0, 0.0, 0.0);
                SetTimerEx( "FinalProces", 4000, 0, "d", playerid );
                StartedSpray[playerid] = 1;
                StartedSpray2[playerid] = 1;
                StartedSprayOn[playerid] = h;
            }
        }
    }
    return true;
}

function CountWallSpray(id,playerid) {
    foreach(Player, i) {
        if(StartedSprayOn[i] == id && i != playerid) return true;
    }
    return false;
}

function FinalProces(playerid) {
    if(IsPlayerConnected(playerid) && StartedSpray[playerid] == 1) {
        ClearAnimations(playerid);
        new string[180];
        new test = 7 + random(6);
        ClanProces[playerid] += test;
        if(ClanProces[playerid] >= 100) {
            new tagname[180];
            new i = StartedSprayOn[playerid];
            format(string, sizeof(string), "{%s}%s (din clanul %s) a reusit sa deseneze complet peretele (turf id %d).", ClanInfo[GraffitiInfo[i][gfOwned]][clColor], GetName(playerid), ClanInfo[PlayerInfo[playerid][pClan]][clName], i);
            SendClanMessage(GraffitiInfo[i][gfOwned], string);
            format(string, sizeof(string), "{%s}%s a reusit sa deseneze complet peretele (turf id %d).", ClanInfo[GraffitiInfo[i][gfOwned]][clColor], GetName(playerid), i);
            SendClanMessage(PlayerInfo[playerid][pClan], string);
            GraffitiInfo[i][gfOwned] = PlayerInfo[playerid][pClan];
            DestroyDynamicObject(GraffitiInfo[i][gfObject]);
            GraffitiInfo[i][gfObject] = CreateDynamicObject(19353, GraffitiInfo[i][gfX], GraffitiInfo[i][gfY], GraffitiInfo[i][gfZ], 0.0, 0.0, GraffitiInfo[i][gfRot]);
            format(tagname, sizeof(tagname), "{%s}%s\n%s", ClanInfo[GraffitiInfo[i][gfOwned]][clColor], ClanInfo[GraffitiInfo[i][gfOwned]][clName], ClanInfo[GraffitiInfo[i][gfOwned]][clTag]);
            SetDynamicObjectMaterialText(GraffitiInfo[i][gfObject], 0, tagname, OBJECT_MATERIAL_SIZE_512x256, "BankGothic Md BT", 60, 1, 0xfff0f0f0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
            
            GraffitiInfo[StartedSprayOn[playerid]][gfAttacked] = 0;
            new query[256];
            mysql_format(SQL, query, sizeof(query), "UPDATE `graffiti` SET `Owned`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pClan], i);
            mysql_tquery(SQL, query, "", "");
            StartedSpray[playerid] = 0;
            StartedSpray2[playerid] = 0;
            StartedSprayOn[playerid] = 0;
        }
        else {
            format(string, sizeof(string), "Continua sa desenezi peretele! (%d%s)", ClanProces[playerid], "%%");
            SCM(playerid, COLOR_GOLD, string);
        }
        StartedSpray2[playerid] = 0;
    }
    return true;
}

Asa am acum functiile, merge bine adica daca cineva incepe sa deseneze intr-un loc si vine altcineva sa deseneze nu poate. Daca merg la alt loc de spray, porneste procentul de la cat aveam inainte, nu de la 0. Cred ca trebuie facut ceva timer ca daca un player incepe sa dea spray si se pune afk, ceilalti nu o sa mai poata da ca le da mesajul ca un player vopseste deja peretele.

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.