Jump to content

[DELETED]Cum pot sa creez deelay la o comanda


cHiEdY
 Share

Recommended Posts

De exemplu, vreau ca, comanda /getmats sa poata fii folosita odata la 30 sec din momentul folosirii, asta pt a evita jobul cu teleport, sunt nou in scripting deci daca se poate cat mai explici :))

CMD:getmats(playerid, params[]) {
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pJob] != 9) return SendClientMessage(playerid,COLOR_WHITE,    "You are not an Arms Dealer.");
        if(IsPlayerInRangeOfPoint(playerid, 5, 597.5396,-1246.9562,18.2512))
        {
            new string1[128],string2[128],string3[128],string4[128],string5[128],string6[128],string7[128],string8[128],string9[128],allstrings[1000];
            new Float:xx,Float:yy,Float:zz,Float: distance1,Float: distance2,Float: distance3,Float: distance4,Float: distance5,Float: distance6,Float: distance7,Float: distance8,Float: distance9;
            GetPlayerPos(playerid, xx, yy, zz);
            distance1 = GetDistanceBetweenPoints(xx,yy,zz,-99.4672,-1579.2155,3.5532);
            distance2 = GetDistanceBetweenPoints(xx,yy,zz,-99.4672,-1579.2155,3.5532);
            distance3 = GetDistanceBetweenPoints(xx,yy,zz,-389.9242,-1151.5128,70.5800);
            distance4 = GetDistanceBetweenPoints(xx,yy,zz,2359.8804,-658.5406,129.0521);
            distance5 = GetDistanceBetweenPoints(xx,yy,zz,2808.8396,-1180.8204,25.5529);
            distance6 = GetDistanceBetweenPoints(xx,yy,zz,1255.9713,244.1114,20.6112);
            distance7 = GetDistanceBetweenPoints(xx,yy,zz,1712.7554,917.2127,12.6207);
            distance8 = GetDistanceBetweenPoints(xx,yy,zz,1038.7993,1303.6626,11.7790);
            distance9 = GetDistanceBetweenPoints(xx,yy,zz,2420.4104,2780.2341,11.7158);


            format(string1,sizeof(string1),"Dilimore          \t\t{9EC42C}(%.0fm)",distance1);
            format(string2,sizeof(string3),"Flint Intersection\t{9EC42C}(%.0fm)",distance2);
            format(string3,sizeof(string3),"Flint County      \t\t{9EC42C}(%.0fm)",distance3);
             format(string4,sizeof(string2),"North Rock        \t{9EC42C}(%.0fm)",distance4);
             format(string5,sizeof(string3),"East beach        \t\t{9EC42C}(%.0fm)",distance5);
             format(string6,sizeof(string3),"MontGomery        \t{9EC42C}(%.0fm)",distance6);
              format(string7,sizeof(string3),"LVA Freight Depot \t{9EC42C}(%.0fm)",distance7);
              format(string8,sizeof(string3),"BlackField        \t\t{9EC42C}(%.0fm)",distance8);
              format(string9,sizeof(string3),"SpinyBed          \t\t{9EC42C}(%.0fm)",distance9); 
            format(allstrings,sizeof(allstrings), "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", string1, string2, string3, string4, string5, string6, string7, string8, string9);
            ShowPlayerDialog(playerid, DIALOG_GETMATS, DIALOG_STYLE_LIST, "Locatia                            Distanta", allstrings, "Select", "Cancel");
        }
        else
        {
            SendClientMessage(playerid, COLOR_YELLOW, "Mergi la checkpoint pentru a colecta materialele.");
            SetPlayerCheckpoint(playerid,597.5396,-1246.9562,18.2512, 10.0);
            GotoMats[playerid] = 1;
        }
    }
    return 1;
}

Link to comment
Share on other sites

Pentru inceput trebuie sa definesti o variabila pe care ulterior trebuie sa o resetezi la conectare.
 

new delayDrugs[ MAX_PLAYERS ];
CMD:getmats(playerid, params[]) {
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pJob] != 9) return SendClientMessage(playerid,COLOR_WHITE,    "You are not an Arms Dealer.");
		if( delayMats[ playerid ] - gettime( ) > 0 )
			return SCMf( playerid, -1, "Asteapta %d secunde pentru a executa aceasta comanda.", delayMats[ playerid ] - gettime( ) );

        if(IsPlayerInRangeOfPoint(playerid, 5, 597.5396,-1246.9562,18.2512))
        {
            new string1[128],string2[128],string3[128],string4[128],string5[128],string6[128],string7[128],string8[128],string9[128],allstrings[1000];
            new Float:xx,Float:yy,Float:zz,Float: distance1,Float: distance2,Float: distance3,Float: distance4,Float: distance5,Float: distance6,Float: distance7,Float: distance8,Float: distance9;
            GetPlayerPos(playerid, xx, yy, zz);
            distance1 = GetDistanceBetweenPoints(xx,yy,zz,-99.4672,-1579.2155,3.5532);
            distance2 = GetDistanceBetweenPoints(xx,yy,zz,-99.4672,-1579.2155,3.5532);
            distance3 = GetDistanceBetweenPoints(xx,yy,zz,-389.9242,-1151.5128,70.5800);
            distance4 = GetDistanceBetweenPoints(xx,yy,zz,2359.8804,-658.5406,129.0521);
            distance5 = GetDistanceBetweenPoints(xx,yy,zz,2808.8396,-1180.8204,25.5529);
            distance6 = GetDistanceBetweenPoints(xx,yy,zz,1255.9713,244.1114,20.6112);
            distance7 = GetDistanceBetweenPoints(xx,yy,zz,1712.7554,917.2127,12.6207);
            distance8 = GetDistanceBetweenPoints(xx,yy,zz,1038.7993,1303.6626,11.7790);
            distance9 = GetDistanceBetweenPoints(xx,yy,zz,2420.4104,2780.2341,11.7158);


            format(string1,sizeof(string1),"Dilimore          \t\t{9EC42C}(%.0fm)",distance1);
            format(string2,sizeof(string3),"Flint Intersection\t{9EC42C}(%.0fm)",distance2);
            format(string3,sizeof(string3),"Flint County      \t\t{9EC42C}(%.0fm)",distance3);
			format(string4,sizeof(string2),"North Rock        \t{9EC42C}(%.0fm)",distance4);
			format(string5,sizeof(string3),"East beach        \t\t{9EC42C}(%.0fm)",distance5);
			format(string6,sizeof(string3),"MontGomery        \t{9EC42C}(%.0fm)",distance6);
			format(string7,sizeof(string3),"LVA Freight Depot \t{9EC42C}(%.0fm)",distance7);
			format(string8,sizeof(string3),"BlackField        \t\t{9EC42C}(%.0fm)",distance8);
			format(string9,sizeof(string3),"SpinyBed          \t\t{9EC42C}(%.0fm)",distance9); 
            format(allstrings,sizeof(allstrings), "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", string1, string2, string3, string4, string5, string6, string7, string8, string9);
            ShowPlayerDialog(playerid, DIALOG_GETMATS, DIALOG_STYLE_LIST, "Locatia                            Distanta", allstrings, "Select", "Cancel");
        
            delayMats[ playerid ] = gettime( ) + 15;
        }
        else
        {
            SendClientMessage(playerid, COLOR_YELLOW, "Mergi la checkpoint pentru a colecta materialele.");
            SetPlayerCheckpoint(playerid,597.5396,-1246.9562,18.2512, 10.0);
            GotoMats[playerid] = 1;
        }
    }
    return 1;
}

Succes!

Edited by ionchyAdv
Link to comment
Share on other sites

  • Hall of Flame🔥

Topic-ul a fost șters deoarece nu ai respectat modelul de postare. Te rugăm sa revii cu alt topic in care să respecți modelul.

Topic șters!

ezgif-com-gif-maker-1-00000.png

Not So Zen SRL

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...