Jump to content

Question

Posted

Problema intalnita (descriere): Pai cand dau /pm la cineva nu apar mesajele in chat nici mie , nici celui care trebuie sa primeasca
Ero(area / rile) / warning-(ul / urile): -
Liniile de cod / sursa / script-ul(obligatoriu):

if(strcmp(cmd, "/pm", true) == 0)
{


   tmp = strtok(cmdtext, idx);
     if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");

            return 1;
     }
     giveplayerid = ReturnUser(tmp);
        if(IsPlayerConnected(giveplayerid)) {
         if(giveplayerid != INVALID_PLAYER_ID) {


          
            GetPlayerName(giveplayerid, giveplayer, 20);
            GetPlayerName(playerid, sendername, 20);
new length = strlen(cmdtext);
  while ((idx < length) && (cmdtext[idx] <= ' ')) {
      idx++;
          }
       new offset = idx;
          new result[128];
       while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
          result[idx - offset] = cmdtext[idx];
             idx++;
               }
                result[idx - offset] = EOS;
                if(!strlen(result)) {
                 SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
                  return 1;
                }
                if((PlayerData[playerid][pAdmin] >= 1) && (PlayerData[playerid][pAgent] >= 0)) {
                
return 1;
}
else {
   format(string, sizeof(string), "(( PM de la %s: %s ))", sendername, (result));
        SendClientMessage(giveplayerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "(( PM catre %s: %s ))", giveplayer, (result));
    SendClientMessage(playerid, COLOR_YELLOW, string);
       return 1;
}
}
}
return 1;

Imagini / Video (optional): -
Ati incercat sa rezolvati singur?: Tot nu reusesc sa fac sa apara mesajele:|

6 answers to this question

Recommended Posts

  • 0
Posted

Am inlocuit comanda asta , cu o comanda din alt gamemode, dar nu apar mesajele, de ex dau /pm ion text , si nu apare nici mie nici celui care trebuie sa primeasca, la coamnda pe care am luat-o , primeam erori , iar la asta nu apar mesajele.

  • 0
  • 0
Posted

Am comanda pusa in gamemode , si nu imi apar mesajele care le trimit, asta doresc sa rezolv, nu alta chestie, legata de comenzile din gamemode, 

Widualk , daca vrei si poti sa mi-o faci, daca nu sa o rezolv pe asta, sa apara mesajele.

  • 0
Posted

Bine omule. Tu ai prostia asta de aici care iti incurca tot scriptul:

if((PlayerData[playerid][pAdmin] >= 1) && (PlayerData[playerid][pAgent] >= 0)) {
return 1;
}

Deci iti dau mai multe variante de comanda, tu o folosesti pe care ai nevoie, nu stiu exact ce vrei tu defapt, dar alegi din acestea.

 

Uite comenzile facute de mine, la care ai nevoie de sscanf(include, plugin .dll si .so)

 

1)Daca vrei ca doar adminii sa dea aceasta comanda pune asta:

if(strcmp(cmd, "/pm", true) == 0)
{
	new targetid;
	if(sscanf(params,"u",targetid))
			return SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
			
	GetPlayerName(targetid, giveplayer, 20);
	GetPlayerName(playerid, sendername, 20);		
	
	if((PlayerData[playerid][pAdmin] < 1)
			return SendClientMessage(playerid, COLOR_RED, "Nu poti folosi aceasta comanda!");
			
	if(targetid == INVALID_PLAYER_ID)		
			return SendClientMessage(playerid, COLOR_RED, "Acest jucator nu este conectat!");
			
	format(string, sizeof(string), "(( PM de la %s: %s ))", sendername, (result));
	SendClientMessage(targetid, COLOR_YELLOW, string);
	format(string, sizeof(string), "(( PM catre %s: %s ))", giveplayer, (result));
	SendClientMessage(playerid, COLOR_YELLOW, string);
	
	
	return 1;
}

2)sau daca vrei si agenti si admini sa foloseasca aceasta comanda uite aici:

if(strcmp(cmd, "/pm", true) == 0)
{
	new targetid;
	if(sscanf(params,"u",targetid))
			return SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
			
	GetPlayerName(targetid, giveplayer, 20);
	GetPlayerName(playerid, sendername, 20);		
			
	if(targetid == INVALID_PLAYER_ID)		
			return SendClientMessage(playerid, COLOR_RED, "Acest jucator nu este conectat!");
			
	if(PlayerData[playerid][pAdmin] >= 1 || PlayerData[playerid][pAgent] >= 1)
	{
		format(string, sizeof(string), "(( PM de la %s: %s ))", sendername, (result));
		SendClientMessage(targetid, COLOR_YELLOW, string);
		format(string, sizeof(string), "(( PM catre %s: %s ))", giveplayer, (result));
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
	else return SendClientMessage(playerid, COLOR_RED, "Nu poti folosi aceasta comanda!");
	
	
	return 1;
}

3)Daca vrei si playerii sa foloseasca aceasta comanda uite-o pe asta:

if(strcmp(cmd, "/pm", true) == 0)
{
	new targetid;
	if(sscanf(params,"u",targetid))
			return SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
			
	GetPlayerName(targetid, giveplayer, 20);
	GetPlayerName(playerid, sendername, 20);		
			
	if(targetid == INVALID_PLAYER_ID)		
			return SendClientMessage(playerid, COLOR_RED, "Acest jucator nu este conectat!");

	format(string, sizeof(string), "(( PM de la %s: %s ))", sendername, (result));
	SendClientMessage(targetid, COLOR_YELLOW, string);
	format(string, sizeof(string), "(( PM catre %s: %s ))", giveplayer, (result));
	SendClientMessage(playerid, COLOR_YELLOW, string);
	
	
	return 1;
}

Asta ca sa iti arat, ca nu e asa de greu sa creezi o comanda ca asta.

Daca o vrei pe aia a ta poti folosi din urmatoarele:

 

1)Daca vrei pentru agenti si admini foloseste-o p-asta:

if(strcmp(cmd, "/pm", true) == 0)
{
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp)) 
	{
		SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
		return 1;
	}
	giveplayerid = ReturnUser(tmp);
	if(IsPlayerConnected(giveplayerid)) 
	{
		if(giveplayerid != INVALID_PLAYER_ID) 
		{

			GetPlayerName(giveplayerid, giveplayer, 20);
			GetPlayerName(playerid, sendername, 20);
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' ')) 
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) 
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result)) 
			{
				SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
				return 1;
			}
			if(PlayerData[playerid][pAdmin] >= 1 || PlayerData[playerid][pAgent] >= 0) 
			{
				format(string, sizeof(string), "(( PM de la %s: %s ))", sendername, (result));
				SendClientMessage(giveplayerid, COLOR_YELLOW, string);
				format(string, sizeof(string), "(( PM catre %s: %s ))", giveplayer, (result));
				SendClientMessage(playerid, COLOR_YELLOW, string);
				return 1;
			}
			else return 1;
		}
	}
	return 1;
}

2)Daca vrei doar pentru admini foloseste-o p-asta:

if(strcmp(cmd, "/pm", true) == 0)
{
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp)) 
	{
		SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
		return 1;
	}
	giveplayerid = ReturnUser(tmp);
	if(IsPlayerConnected(giveplayerid)) 
	{
		if(giveplayerid != INVALID_PLAYER_ID) 
		{

			GetPlayerName(giveplayerid, giveplayer, 20);
			GetPlayerName(playerid, sendername, 20);
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' ')) 
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) 
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result)) 
			{
				SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
				return 1;
			}
			if(PlayerData[playerid][pAdmin] >= 1) 
			{
				format(string, sizeof(string), "(( PM de la %s: %s ))", sendername, (result));
				SendClientMessage(giveplayerid, COLOR_YELLOW, string);
				format(string, sizeof(string), "(( PM catre %s: %s ))", giveplayer, (result));
				SendClientMessage(playerid, COLOR_YELLOW, string);
				return 1;
			}
			else return 1;
		}
	}
	return 1;
}

3)iar daca vrei pt toti playerii foloseste-o p-asta:

if(strcmp(cmd, "/pm", true) == 0)
{
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp)) 
	{
		SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
		return 1;
	}
	giveplayerid = ReturnUser(tmp);
	if(IsPlayerConnected(giveplayerid)) 
	{
		if(giveplayerid != INVALID_PLAYER_ID) 
		{
			GetPlayerName(giveplayerid, giveplayer, 20);
			GetPlayerName(playerid, sendername, 20);
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' ')) 
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) 
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result)) 
			{
				SendClientMessage(playerid, COLOR_GREY, "/pm <playerid/name> <text>");
				return 1;
			}
			format(string, sizeof(string), "(( PM de la %s: %s ))", sendername, (result));
			SendClientMessage(giveplayerid, COLOR_YELLOW, string);
			format(string, sizeof(string), "(( PM catre %s: %s ))", giveplayer, (result));
			SendClientMessage(playerid, COLOR_YELLOW, string);
			return 1;
		}
	}
	return 1;
}

Sper ca tu sa inveti din ce ti-am dat. Nu am facut o demonstratie ca eu sunt "mare si tare/beton/number 1 etc.) ci doar ca sa iti arat ca e foarte simplu sa o faci sa mearga.

  • 0
Posted

Topic Closed . Nu ai incercat in niciun fel sa rezolvi comanda daca doar ai copiat-o din alt gamemode .

Guest
This topic is now closed to further replies.
×
×
  • 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.