Jump to content
  • 0

Problema comanda /l


OldeR

Question

CMD:l(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(IsPlayerConnected(playerid))
    {
        if (PlayerInfo[playerid][pLeader] >= 1 || PlayerInfo[ playerid ][ pAdmin ] )
        {
            new sendername[30],mesajelc[250],string[250];
               GetPlayerName(playerid, sendername, sizeof(sendername));
            if(sscanf(params, "s[250]",mesajelc)) return SCM(playerid,COLOR_WHITE,"{73a2ad}Syntax: /l <Message>");
            {
                if (PlayerInfo[playerid][pLeader] == 1)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Los Santos Police Departament %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 2)
                {
                     format(string, sizeof(string), "{73a2ad} (/l) Leader FBI %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 3)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader National Guard %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 4)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Los Aztecas %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 5)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Groove Street %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 6)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Los Vagos %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == ?
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Las Venturas Police Departament %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 9)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader News Reporters %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 10)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Ballas %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 11)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Hitmen %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 12)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader School Instructors %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 13)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Taxi Cab Company %s: %s",sendername, mesajelc);
                 }
                 else if (PlayerInfo[playerid][pLeader] == 14)
                {
                     format(string, sizeof(string), "{73a2ad}(/l) Leader Paramedics %s: %s",sendername, mesajelc);
                 }
                if( PlayerInfo[ playerid ][ pAdmin ] )
                {
                    format(string, sizeof(string), "{73a2ad}(/l) Admin %s: %s", PlayerInfo[ playerid ][ pAdmin ],sendername, mesajelc);
                }
                  LeaderChat(COLOR_WHITE, string);
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "{FFB870}Only leaders can use this command.");
            return 1;
        }
    }
    return 1;
}

Cand dau sa scriu pe /l sunt admin nu imi apare nimic imi apre doar numele meu , dar la lideri merge sa scrie.

sa-mp-066.png

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
if( PlayerInfo[ playerid ][ pAdmin ] )
{
	format(string, sizeof(string), "{73a2ad}(/l) Admin %s: %s",sendername, mesajelc);
}

Trebuie sa scoti PlayerInfo[ playerid ][ pAdmin ] deoarce tu transmiti prin parametrii doar sendername si mesajelc adica %s %s.

 

Daca vrei sa pui rang-ul adminului adica nivelul trebuie sa adaugi %d adica.

if( PlayerInfo[ playerid ][ pAdmin ] )
{
	format(string, sizeof(string), "{73a2ad}(/l) Admin(%d) %s: %s", PlayerInfo[ playerid ][ pAdmin ],sendername, mesajelc);
}

 

%d - decimale sau poti folosi si %i care inseamna intreg.

%s - insemnand string

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

Link to comment
Share on other sites

  • 0
Acum 23 minute, Gireada a spus:
if( PlayerInfo[ playerid ][ pAdmin ] )
{
	format(string, sizeof(string), "{73a2ad}(/l) Admin %s: %s",sendername, mesajelc);
}

Trebuie sa scoti PlayerInfo[ playerid ][ pAdmin ] deoarce tu transmiti prin parametrii doar sendername si mesajelc adica %s %s.

 

Daca vrei sa pui rang-ul adminului adica nivelul trebuie sa adaugi %d adica.

if( PlayerInfo[ playerid ][ pAdmin ] )
{
	format(string, sizeof(string), "{73a2ad}(/l) Admin(%d) %s: %s", PlayerInfo[ playerid ][ pAdmin ],sendername, mesajelc);
}

 

%d - decimale sau poti folosi si %i care inseamna intreg.

%s - insemnand string

Frate nu merge sa scriu pe /l nu imi apare nimic adica , ce pot face ??

Link to comment
Share on other sites

  • 0

atata cod inutil, putea fi totul redus la:

if(PlayerInfo[playerid][Leader] != 0) 
	format(string, sizeof(string), "Leader %s %s: %s", FactionName(PlayerInfo[playerid][Leader]), GetName(playerid), text);



si cam asa arata FactionName(PlayerInfo[playerid][Leader]) :

stock FactionName(id) {
	new string[64];
	switch(id) {
		case 1: string = "LSPD";
		case 2: string = "SFPD";
		etc..
	}
	return string;
}

Iar tu acolo ai pus 3 parametri, dar de fapt sunt 2. 

format(string, sizeof(string), "{73a2ad}(/l) Admin %s: %s", PlayerInfo[ playerid ][ pAdmin ],sendername, mesajelc);

fii mai atent

76561198110915771.pngAddFriend.png

Link to comment
Share on other sites

  • 0
Acum 39 minute, Mento a spus:

atata cod inutil, putea fi totul redus la:

if(PlayerInfo[playerid][Leader] != 0) 
	format(string, sizeof(string), "Leader %s %s: %s", FactionName(PlayerInfo[playerid][Leader]), GetName(playerid), text);



si cam asa arata FactionName(PlayerInfo[playerid][Leader]) :

stock FactionName(id) {
	new string[64];
	switch(id) {
		case 1: string = "LSPD";
		case 2: string = "SFPD";
		etc..
	}
	return string;
}

Iar tu acolo ai pus 3 parametri, dar de fapt sunt 2. 

format(string, sizeof(string), "{73a2ad}(/l) Admin %s: %s", PlayerInfo[ playerid ][ pAdmin ],sendername, mesajelc);

fii mai atent

Da man dar la admin ? cand dau /l nu imi apare nimic ca admin si ca lider merge asta vreau sa spun

 

Link to comment
Share on other sites

  • 0

Ai gresit parametrii:

     if( PlayerInfo[ playerid ][ pAdmin ] )
                {
                    format(string, sizeof(string), "{73a2ad}(/l) Admin %s: %s", PlayerInfo[ playerid ][ pAdmin ],sendername, mesajelc);
                }

E si normal, ai acolo '%s' care ia valoarea PlayerInfo[playerid][pAdmin], nu functioneaza asa, daca pui string trimite un string ca parametru, nu o valoare. La fel si la urmatorul %s, apare numele.

 

     if( PlayerInfo[ playerid ][ pAdmin ] ) {
            format(string, sizeof(string), "{73a2ad}(/l) Admin %s (%d): %s", sendername, PlayerInfo[playerid][pAdmin], mesajelc);
      }

 

76561198110915771.pngAddFriend.png

Link to comment
Share on other sites

  • 0

Ti-am rescris comanda, cred ca nu te superi.

CMD:l(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if (PlayerInfo[playerid][pLeader] < 1 && PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_WHITE, "{FFB870}Only leaders can use this command.");
	new sendername[30], mesajelc[128], string[160];
	GetPlayerName(playerid, sendername, sizeof(sendername));
	if(sscanf(params, "s[128]", mesajelc)) return SCM(playerid,0x73a2adFF,"Syntax: /l <Message>");
	new facN[33];
	switch(PlayerInfo[playerid][pLeader]) {
		case 1: facN = "Los Santos Police Departament";
		case 2: facN = "FBI";
		case 3: facN = "National Guard";
		case 4: facN = "Los Aztecas";
		case 5: facN = "Groove Street";
		case 6: facN = "Los Vagos";
		case 7: facN = "Las Venturas Police Departament"; // Pune ID-ul corect aici
		case 9: facN = "News Reporters";
		case 10: facN = "Ballas";
		case 11: facN = "Hitmen";
		case 12: facN = "School Instructors";
		case 13: facN = "Taxi Cab Company";
		case 14: facN = "Paramedics";
		default: facN = "";
	}
	format(string, 160, "(/l) %s %s %s: %s", (PlayerInfo[playerid][pLeader] == 0) ? ("Admin") : ("Leader"), facN, sendername, mesajelc);
	LeaderChat(0x73a2adFF, string);
    return 1;
}

 

Edited by Lunoxx
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.