Jump to content

Optimizare comanda


Pitbul97

Recommended Posts

Am o problema cu, comanda asta, cand dai /set din prima seteaza rank la factiune cuiva pe 0

 

CMD:set(playerid, params[])
{
	new id, item[25], ammount;
	if(PlayerInfo[playerid][pAdmin] < 4)return SCM(playerid, -1, AdminOnly);
	//if(PinLogged[playerid] == 0)return SCM(playerid, COLOR_LIGHTRED, "Trebuie sa introduci pin-ul mai intai.(/pin)");// daca nu folositi gm-ul de la mine este obligatoriu sa schimbati acest rand
	if(sscanf(params, "us[250]i", id, item, ammount))
	{
	    SCM(playerid, COLOR_GREY,"Syntaxl: /set <id> <item> <ammount> ");
	    SCM(playerid, COLOR_GREY, "Avabile Items: Group, Rank, Money, BankMoney, PlayedHours, PremiumPoints, PremiumAccount, FP");
	}
	if(id == INVALID_PLAYER_ID)return SCM(playerid, COLOR_LIGHTRED, "ID sau nume incorect !");
	if(strcmp(item, "Rank", true) == 0)
	{
		if(PlayerInfo[id][pMember] != 0)
		{
			PlayerInfo[id][pRank] = ammount;
			new str[256];
			mysql_format(SQL,str,sizeof(str),"UPDATE users SET `Rank`='%d' WHERE `name`='%s'",PlayerInfo[id][pRank],PlayerInfo[id][pNormalName]);
			mysql_tquery(SQL,str,"","");
			new IDName[25], AdminName[25];
			GetPlayerName(id, IDName, sizeof(IDName));
			GetPlayerName(playerid, AdminName, sizeof(AdminName));
			new text[128];
			format(text, sizeof(text), "AdmWarning: %s i-a setat lui %s rank-ul in factiune la rank %d.", AdminName, IDName, ammount);
			ABroadCast(COLOR_ORANGE, text, 4);
			SCM(id, -1, "Your rank in this faction has been changed.");
		}
	}
	else if(strcmp(item,"Group",true) == 0)
	{
	    new name[25], name2[25], string[128], string2[128];
		GetPlayerName(playerid, name, sizeof(name));
		GetPlayerName(id, name2, sizeof(name2));
		new ftext[50];
		if(ammount == 12 || ammount == 7) return SCM(playerid, -1, "Invalid faction ID");
		if(ammount == 0)return SCM(playerid, COLOR_GREY, "Foloseste /auninvite");
		if(ammount == 1) { ftext = "Los Santos Police Departament"; } //Police Force
		else if(ammount == 2) { ftext = "Federal Bureau Of Investigation"; } //FBI
		else if(ammount == 3) { ftext = "National Guard"; } //National Guard
		else if(ammount == 4) { ftext = "Los Aztecas"; } //Los Aztecas
		else if(ammount == 5) { ftext = "Grove Street"; } //Grove Street
		else if(ammount == 6) { ftext = "Los Vagos"; } //Los Vagos
		else if(ammount == 8) { ftext = "Las Venturas Police Departament"; } //LVPD
		else if(ammount == 9) { ftext = "News Reporter"; } //News Reporter
		else if(ammount == 10) { ftext = "Ballas"; } //Ballas
        else if(ammount == 11) { ftext = "Hitman Agency"; } //The Agency
        else if(ammount == 13) { ftext = "Taxi Los Santos"; } //Los Santos Taxi
        else if(ammount == 14) { ftext = "Las Venturas Paramedic Departament"; } //Paramedic
        else if(ammount == 15) { ftext = "The Rifa"; } //Rifa
        else if(ammount == 16) { ftext = "The Russian Mafia"; } // The russian
        else if(ammount == 17) { ftext = "Taxi LV"; } // Taxi LV
	    format(string, sizeof(string),"Administratorul %s te-a adaugat ca membru in factiunea %s",name,ftext);
	    format(string2, sizeof(string2),"AdmWarning: %s l-a adaugat ca membru pe %s in factiunea %s",name, name2, ftext);
		PlayerInfo[id][pMember] = ammount;
		new str[356];
		format(str, sizeof(str),"UPDATE users SET `Member`='%d' WHERE `name`='%s'",PlayerInfo[id][pMember],PlayerInfo[id][pRank],PlayerInfo[id][pNormalName]);
		mysql_query(SQL, str);
		ABroadCast(COLOR_LIGHTRED,string2, 4);
		SCM(id, COLOR_DBLUE, string);
	}
	else if(strcmp(item, "Money", true) == 0)
	{
		PlayerInfo[id][pCash] = ammount;
        GivePlayerCash(id, ammount);
        Update(id, pCashx);
        new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		new text[128];
		format(text, sizeof(text), "AdmWarning: %s i-a setat lui %s bani in mana la suma de %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		SCM(id, -1, "You recived some money.");
	}
	else if(strcmp(item, "PremiumPoints", true) == 0)
	{
        PlayerInfo[id][pPremiumPoints] = ammount;
		Update(id,pPremiumPointsx);
		new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		new text[128];
		format(text, sizeof(text), "AdmWarning: %s i-a setat lui %s punctele premium la %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		SCM(id, -1, "Your recived some premium points.");
	}
	else if(strcmp(item, "BankMoney", true) == 0)
	{
		PlayerInfo[id][pAccount] = ammount;
		Update(id, pBank);
		new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		new text[128];
		format(text, sizeof(text), "AdmWarning: %s i-a setat lui %s bani in banca la suma de %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		SCM(id, -1, "Your recived some money in bank.");
	}
    else if(strcmp(item, "PlayedHours", true) == 0)
	{
	    PlayerInfo[id][pConnectTime] = ammount;
        Update(id,pConnectTimex);
        new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		new text[128];
		format(text, sizeof(text), "AdmWarning: %s i-a setat lui %s orele jucate la %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		SCM(id, -1, "Your played hours has been changed.");
	}
	else if(strcmp(item, "PremiumAccount", true) == 0)
	{
	    if(ammount < 0 || ammount > 1)SCM(playerid, COLOR_GREY, "1 = Cont premium | 0 = Fara cont premium");
        PlayerInfo[id][pPremiumAccount] = ammount;
		Update(id, pPremiumAccountx);
		new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		new text[128];
		format(text, sizeof(text), "AdmWarning: %s i-a setat lui %s rank-ul in factiune la rank %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		if(ammount == 0)return SCM(id, -1, "Your premium account has been removed.");
		if(ammount == 1)return SCM(id, -1, "You recived a premium account .");
	}
	else if(strcmp(item, "FP", true) == 0)
	{
        PlayerInfo[id][pFpunish] = ammount;
    	Update(id,pFpunishx);
        new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		new text[128];
		format(text, sizeof(text), "AdmWarning: %s i-a setat lui %s Faction Punish-ul la  %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		SCM(id, -1, "Your FP has been changed.");
	}
	else
	{
	    SCM(playerid, COLOR_GREY, "Avabile Items: Group, Rank, Money, BankMoney, PlayedHours, PremiumPoints, PremiumAccount, FP");
	}
	return 1;


 

Edited by Pitbul97
Link to comment
Share on other sites

Asta nu ar trebui sa se intample pentru ca ai

Citat

if(id == INVALID_PLAYER_ID)return SCM(playerid, COLOR_LIGHTRED, "ID sau nume incorect !");

Care iti verifica primul parametru si daca e invalid adica nu ai introdus nimic) pur si simplu nu se executa. (asta daca ai un space intre ) si return )

Ti-as recomanda sa folosesti unltima versiunea de sscanf

https://github.com/maddinat0r/sscanf/releases/tag/v2.8.3

Descarca versiunea de win32, pune fisierul din folderul pawno>include sscanf2.inc si inlocuieste pe cel existent in folderul cu acelasi nume dingm tau. De asemea poti face cu plugin si sa inlocuiesti cu ce ai tu in folderul din gm

Este posibil sa ai o versiune mai veche care are aumite buguri

  • Like 2
Link to comment
Share on other sites

3 hours ago, George-Valentin Hulpoi said:

optimizarea tine de viteza cu care se executa, nu ca nu-ti merge tie..

am intrat degeaba aici, just a guy who doesn't know what he's doing.

am explicat prost, defapt eu vroiam sa modific pentru ca aveam probleme atunci cand scrii /set automat iti seteaza rank 0 in factiune. 

 

Se poate da am rezolvat T/C

Edited by Pitbul97
Link to comment
Share on other sites

Acum 20 ore, Banditul a spus:

Asta nu ar trebui sa se intample pentru ca ai

Care iti verifica primul parametru si daca e invalid adica nu ai introdus nimic) pur si simplu nu se executa. (asta daca ai un space intre ) si return )

Ti-as recomanda sa folosesti unltima versiunea de sscanf

https://github.com/maddinat0r/sscanf/releases/tag/v2.8.3

Descarca versiunea de win32, pune fisierul din folderul pawno>include sscanf2.inc si inlocuieste pe cel existent in folderul cu acelasi nume dingm tau. De asemea poti face cu plugin si sa inlocuiesti cu ce ai tu in folderul din gm

Este posibil sa ai o versiune mai veche care are aumite buguri

Ultima versiune oferita de Y_Less, este 2.10.2

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
Reply to this topic...

×   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.

  • Similar Content

    • By xLinix96
      Salut, asta este prima mea postare pe aceasta comunitate, astazi vreau sa va arat cum sa creati o comanda /flymode, stiu ca este o comanda foarte simpla, dar sunt unii incepatori care nu stiu sa o faca.
       
      Pentru inceput aveti nevoie de un include.
      #include <fly>
      Il gasiti aici: http://www.solidfiles.com/d/289d6c8fdf/
       
       
      Acum vom face comanda:
      CMD:fly(playerid, params[])
      {
          if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te comenctezi."); // aici verificam daca esti conectat
          if(IsPlayerConnected(playerid)) 
          {
              if(PlayerInfo[playerid][pAdmin] >= 1) // aici punem nivelul de admin necesar pentru a folosii comanda.
              {
                  new sendername[30],string[256];
                  if(flymode[playerid] == 0)
                  {
                      GetPlayerName(playerid, sendername, sizeof(sendername)); // aici obtinem numele adminuui.
                      togfind[playerid] = 0;
                      flymode[playerid] = 1;
                      format(string,sizeof(string),"{DFF230}%s este acum in modul fly-mode.", sendername); 
                      ABroadCast(COLOR_ORANGE,string,1);
                      InitFly(playerid);
                      StartFly(playerid);
                      SetPlayerHealthEx(playerid, 10000000); // aici setam hp-ul.
                  }
                  else
                  {
                      GetPlayerName(playerid, sendername, sizeof(sendername)); // iar de aici oprim fly-ul.
                      togfind[playerid] = 1;
                      flymode[playerid] = 0;
                      format(string,sizeof(string),"{F89AD6}Ai oprit fly-mode-ul", sendername);
                      SCM(playerid, COLOR_GREEN, string);
                      StopFly(playerid);
                      SetPlayerHealthEx(playerid, 100); // 
                  }
              }
              else return SendClientMessage(playerid, COLOR_ERROR, AdminOnly);
          }
          return 1;
      }
       
      Sper ca v-am ajutat, nu este cine site ce sistem.
       
       
    • By FlobertRO
      Cum pot schimba o comanda de tipul "strcmp" in "cmd" ? un exemplu daca se poate, multumesc <3
    • By StrypS
      YCMD:bonus(playerid, params[], help) {
          if(PlayerInfo[playerid][pLevel] > 1)
              return true;
          new string[43];
          new money = PlayerInfo[playerid][pLevel] * 500000 + random(8000000);
          new lvlbonus = PlayerInfo[playerid][pLevel] * 3 + random(5);
          new ppbonus = PlayerInfo[playerid][pLevel] * 10 + random(50);
          SetPlayerScore(playerid, lvlbonus);
          PlayerInfo[playerid][pLevel] += lvlbonus;
          UpdateVar(playerid, "Level", 3);
          PlayerInfo[playerid][pPremiumPoints] += ppbonus;
          UpdateVar(playerid, "PremiumPoints", 3);
          GivePlayerCash(playerid, 1, money);
          format(string, sizeof(string), "Server Bonus Random: Ai primit %s PremiumPoints, Level %d si %i $.", ppbonus, lvlbonus, FormatNumber(money));
          SCM(playerid, -1, string);
          return true;
      }

       
    • By TheGodfather
      Salut, aveti idee cum pot face o comanda prin care playerii sa se poata reconecta pe server fara sa inchida sampul? Gen sa dea /relog si sa le incarce din nou toate datele, sa puna din nou parola etc.
    • By TheGodfather
      Salut, vreau sa fac o comanda /lastchat cu care sa pot sa vad ultimele x mesaje ale unui jucator. Am incercat asa dar nu imi afiseaza nimic.
      YCMD:lastchat(playerid, params[], help) {
          if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Wait %d seconds.", aspam[playerid]);
          if(PlayerInfo[playerid][pAdmin] < 😎 return SCM(playerid,COLOR_WHITE,AdminOnly);
          new giveplayerid[25],id,cont,name[30];
          if(sscanf(params, "s[25]d", giveplayerid, id)) return SCM(playerid,COLOR_GREY, "Syntax: {FFFFFF}/lastchat <name> <number of messages>");
          cont = MySQLCheckAccount(giveplayerid);
          if(cont == 0) return SCM(playerid,COLOR_ERROR,"Error:{FFFFFF} This account was not found in the database!");
          GetPlayerName(playerid, name, sizeof name);
          //
          new szQuery[256], string[180], MemberString[1024], szResult[180], text[180],TitleString[180];
          format(szQuery, sizeof(szQuery), "SELECT * FROM `logs` WHERE `Name`='%s' ORDER BY `ID` DESC LIMIT %d", GetName(playerid), id);
          new Cache: result = mysql_query(SQL, szQuery);
          for(new i, j = cache_num_rows(); i != j; ++i)
          {
              cache_get_field_content(i, "player", szResult); format(name, 256, szResult);
              cache_get_field_content(i, "Text", szResult);  format(text, 256, szResult);
              format(string, sizeof(string), "%s", text);strcat(MemberString, string, sizeof(MemberString));
          }
          cache_delete(result);
          format(TitleString, sizeof(TitleString), "Last %d messages from player %s.", id, name);
          ShowPlayerDialog(playerid, DIALOG_LASTCHAT, DIALOG_STYLE_TABLIST_HEADERS, TitleString, MemberString, "Ok", "Exit");
          //
          return 1;
      }
      case DIALOG_LASTCHAT: {
                  if(!response) return true;
              }
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.