Help with command /set
#1

Hi guys, when I use comand like "/set" without id, item and ammount, the command set automat rank 1 in faction, how can I make the command to show text with "Syntax" and "Available Items" ?

Command:
Код:
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)");
	if(sscanf(params, "us[250]i", id, item, ammount))
	{
  		SCM(playerid, COLOR_GREY,"Syntaxl: /set <id> <item> <ammount> ");
  	  	SCM(playerid, COLOR_GREY, "Available Items: Group, Rank, Money, BankMoney, PlayedHours, RespecPoints.");
   	 	SCM(playerid, COLOR_GREY, "Available Items: PremiumPoints, PremiumAccount, Level, FP, TeamViewer, VIP, Skin.");
	}
	if(id == INVALID_PLAYER_ID)return SCM(playerid, COLOR_LIGHTRED, "ID sau nume incorect !");
	if(strcmp(item, "Rank", true) == 0)
	{
		if(PlayerInfo[id][pMember] >= 1)
		{
			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.");
		}
	}
Reply
#2

PHP код:
    if(sscanf(params"us[250]i"iditemammount))
    {
          
SCM(playeridCOLOR_GREY,"Syntaxl: /set <id> <item> <ammount> ");
            
SCM(playeridCOLOR_GREY"Available Items: Group, Rank, Money, BankMoney, PlayedHours, RespecPoints.");
            
SCM(playeridCOLOR_GREY"Available Items: PremiumPoints, PremiumAccount, Level, FP, TeamViewer, VIP, Skin.");
    } 
Add a return in the code above to avoid the rest of the function from executing.
Reply
#3

Quote:
Originally Posted by Troydere
Посмотреть сообщение
PHP код:
    if(sscanf(params"us[250]i"iditemammount))
    {
          
SCM(playeridCOLOR_GREY,"Syntaxl: /set <id> <item> <ammount> ");
            
SCM(playeridCOLOR_GREY"Available Items: Group, Rank, Money, BankMoney, PlayedHours, RespecPoints.");
            
SCM(playeridCOLOR_GREY"Available Items: PremiumPoints, PremiumAccount, Level, FP, TeamViewer, VIP, Skin.");
    } 
Add a return in the code above to avoid the rest of the function from executing.
I solved this but when I type just "/set" command set me rank 0 automatically, why ?
Reply
#4

I wonder why. Can you show the full command code, please?
Reply
#5

Quote:
Originally Posted by Troydere
Посмотреть сообщение
I wonder why. Can you show the full command code, please?
Yes, this is

Код:
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)");
	if(sscanf(params, "us[10]i", id, item, ammount))
	SendClientMessage(playerid, COLOR_GREY,"Syntaxl: /set <id> <item> <ammount> ");
 	SendClientMessage(playerid, COLOR_GREY, "Available Items: Group, Rank, Money, BankMoney, PlayedHours, RespecPoints.");
 	SendClientMessage(playerid, COLOR_GREY, "Available Items: PremiumPoints, PremiumAccount, Level, FP, TeamViewer, VIP, Skin.");
	if(strcmp(item, "Rank", true) == 0)
	{
		if(PlayerInfo[id][pMember] >= 1)
		{
			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 == 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 == 12) { ftext = "School Instructors LV"; } //School Instructors
        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
        else if(ammount == 18) { ftext = "Government"; } // Government
	    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;
		PlayerInfo[id][pModel] = ChosenSkin[id];
		gTeam[id] = PlayerInfo[id][pTeam];
		new str[356];
		mysql_format(SQL,str,sizeof(str),"UPDATE users SET `Member`='%d' WHERE `name`='%s'",PlayerInfo[id][pMember],PlayerInfo[id][pNormalName]);
		mysql_tquery(SQL,str,"","");
		PlayerInfo[id][pRank] = 1;
		mysql_format(SQL,str,sizeof(str),"UPDATE users SET `Rank`='%d' WHERE `name`='%s'",PlayerInfo[id][pRank],PlayerInfo[id][pNormalName]);
		mysql_tquery(SQL,str,"","");
		ABroadCast(COLOR_LIGHTRED,string2, 4);
		SCM(id, COLOR_DBLUE, string);
	}
	else if(strcmp(item, "Money", true) == 0)
	{
		PlayerInfo[id][pCash] = 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, "Level", true) == 0)
	{
		PlayerInfo[id][pLevel] = ammount;
        Update(id, pLevelx);
        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 nivelul la %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		SCM(id, -1, "You recived some level.");
	}
	else if(strcmp(item, "Skin", true) == 0)
	{
		if(ammount < 0 || ammount > 311) return SendClientMessage(playerid, COLOR_WHITE, "{cef0ac}Wrong skin ID(0-311).");
		new IDName[25], AdminName[25], string[64];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		PlayerInfo[id][pModel] = ammount;
		format(string, sizeof(string), "Your skin has been changed by Admin %s", AdminName);
		SendClientMessage(id, COLOR_WHITE, string);
		format(string, sizeof(string), "You have given %s skin to %d.", IDName,ammount);
		SendClientMessage(playerid, COLOR_WHITE, string);
		SetPlayerSkin(id, PlayerInfo[id][pModel]);
		new str2[128];
		mysql_format(SQL,str2,sizeof(str2),"UPDATE users SET `Money`='%d',`Model`='%d' WHERE `name`='%s'",GetPlayerCash(playerid),PlayerInfo[id][pModel],PlayerInfo[id][pNormalName]);
		mysql_tquery(SQL,str2,"","");
	}
	else if(strcmp(item, "RespectPoints", true) == 0)
	{
		PlayerInfo[id][pExp] = ammount;
		Update(id, pRP);
		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 RP-urile la %d.", AdminName, IDName, ammount);
		ABroadCast(COLOR_ORANGE, text, 4);
		SCM(id, -1, "An admin update your Respect Points.");
	}
	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, "An admin update your 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 contul premium la %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 if(strcmp(item, "VIP", true) == 0)
	{
	    if(ammount > 1 || ammount < 0)return SCM(playerid, COLOR_GREY,"1 - VIP | 0 - Remove VIP.");
		if(PlayerInfo[playerid][pAdmin] < 6)return SCM(playerid, -1, AdminOnly);
        new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		if(ammount == 1)
		{
		    new sendername[30],string[200],str[356];
			GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "Your account has been set to VIP by admin %s.", sendername);
			SendClientMessage(id, COLOR_YELLOW, string);
			PlayerInfo[id][pVIP] = ammount;
			Update(id, pVIPx);
			format(str, sizeof(str),"UPDATE users SET `VIP`='%d' WHERE `name`='%s'",PlayerInfo[id][pTW],PlayerInfo[id][pNormalName]);
			mysql_query(SQL, str);
		}
		if(ammount == 0)
		{
		    new sendername[30],string[200],str[356];
			GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "Your VIP account have ben removed by admin %s.", sendername);
			SendClientMessage(id, COLOR_YELLOW, string);
			PlayerInfo[id][pVIP] = ammount;
			Update(id, pVIPx);
			format(str, sizeof(str),"UPDATE users SET `VIP`='%d' WHERE `name`='%s'",PlayerInfo[id][pTW],PlayerInfo[id][pNormalName]);
			mysql_query(SQL, str);
		}
 	}
	else if(strcmp(item, "TeamViewer", true) == 0)
	{
	    if(ammount > 1 || ammount < 0)return SCM(playerid, COLOR_GREY,"1 - TeamViewer Tester | 0 - Remove TeamViewer Tester.");
		if(PlayerInfo[playerid][pAdmin] < 6)return SCM(playerid, -1, AdminOnly);
        new IDName[25], AdminName[25];
		GetPlayerName(id, IDName, sizeof(IDName));
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		if(ammount == 1)
		{
		    new sendername[30],giveplayer[30],string[200],str[356];
		    GetPlayerName(id, giveplayer, sizeof(giveplayer));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			printf("AdmCmd: %s has promoted %s to TeamViewer tester.", sendername, giveplayer);
			format(string, sizeof(string), "You've been promoted to TeamViewer tester rank, by %s.", sendername);
			SendClientMessage(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "You have promoted %s to TeamViewer tester rank.", giveplayer);
			SendClientMessage(playerid, COLOR_YELLOW, string);
			format(string, sizeof(string), "* Admin %s promoted %s to  TeamViewer tester rank.", sendername,giveplayer);
			ABroadCast(COLOR_ADMCHAT,string,1);
			HLChat(COLOR_ADMCHAT,string);
			PlayerInfo[id][pTW] = ammount;
			Update(id, pTWx);
			format(str, sizeof(str),"UPDATE users SET `TW`='%d' WHERE `name`='%s'",PlayerInfo[id][pTW],PlayerInfo[id][pNormalName]);
			mysql_query(SQL, str);
		}
		if(ammount == 0)
		{
		    new sendername[30],giveplayer[30],string[200],str[356];
		    GetPlayerName(id, giveplayer, sizeof(giveplayer));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			printf("AdmCmd: %s has demoted %s from TeamViewer tester rank.", sendername, giveplayer);
			format(string, sizeof(string), "You've been demoted to TeamViewer rank, by %s.", sendername);
			SendClientMessage(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "You have demoted %s from TeamViewer tester rank.", giveplayer);
			SendClientMessage(playerid, COLOR_YELLOW, string);
			format(string, sizeof(string), "* Admin %s demoted %s from TeamViewer tester rank.", sendername,giveplayer);
			ABroadCast(COLOR_ADMCHAT,string,1);
			HLChat(COLOR_ADMCHAT,string);
			PlayerInfo[id][pTW] = ammount;
			Update(id, pTWx);
			format(str, sizeof(str),"UPDATE users SET `TW`='%d' WHERE `name`='%s'",PlayerInfo[id][pTW],PlayerInfo[id][pNormalName]);
			mysql_query(SQL, str);
		}
	}
	else
	{
	    SCM(playerid, COLOR_GREY, "Avabile Items: Group, Rank, Money, BankMoney, PlayedHours, RespecPoints.");
	    SCM(playerid, COLOR_GREY, "Avabile Items: PremiumPoints, PremiumAccount, Level, FP, TeamViewer, VIP.");
	}
	return 1;
}
Reply
#6

You did not solve the problem I pointed out in my first response. Fix that and try your command again.
Reply
#7

Quote:
Originally Posted by Troydere
Посмотреть сообщение
You did not solve the problem I pointed out in my first response. Fix that and try your command again.
I added this
Код:
if(sscanf(params, "us[250]i", id, item, ammount))
    {
   		SCM(playerid, COLOR_GREY,"Syntaxl: /set <id> <item> <ammount> ");
     	SCM(playerid, COLOR_GREY, "Available Items: Group, Rank, Money, BankMoney, PlayedHours, RespecPoints.");
      	SCM(playerid, COLOR_GREY, "Available Items: PremiumPoints, PremiumAccount, Level, FP, TeamViewer, VIP, Skin.");
    }
but where you want to add a return ?
Reply
#8

At the most end of that conditional statement. Right before the closing bracket.
Reply
#9

Quote:
Originally Posted by Troydere
Посмотреть сообщение
At the most end of that conditional statement. Right before the closing bracket.
Aaaa, I know now what you want to make, I put return above the ultimate SCM and command has stoped, thx for explanation.

I put like that and works:

Код:
if(sscanf(params, "us[250]i", id, item, ammount))
    {
   		SCM(playerid, COLOR_GREY,"Syntaxl: /set <id> <item> <ammount> ");
     	SCM(playerid, COLOR_GREY, "Available Items: Group, Rank, Money, BankMoney, PlayedHours, RespecPoints.");
      	SCM(playerid, COLOR_GREY, "Available Items: PremiumPoints, PremiumAccount, Level, FP, TeamViewer, VIP, Skin.");
		return 1;
    }
Reply
#10

Quote:
Originally Posted by RobyRbb
Посмотреть сообщение
Aaaa, I know now what you want to make, I put return above the ultimate SCM and command has stoped, thx for explanation.
Exactly. You can read more about the return statement in the following link.

https://sampwiki.blast.hk/wiki/Keywords:Statements#return
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)