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.

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