[HELP] /adjust rank
#1

I'm using the LA-RP script for my server. I want to make something that people can /adjust rank [id] [name] So that you don't need to give a rank 1 or 2 or 3 but just a name.

This is my /adjust script. Does anyone has suggestions of making this? Because I really don't know where to start. It needs to be saved tho.

Код:
	if(strcmp(cmd, "/adjust", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pFMember] == 255)
	        {
	            SendClientMessage(playerid, COLOR_GREY, "   You are not in a Family !");
	            return 1;
	        }
	        new family = PlayerInfo[playerid][pFMember];
	        new wstring[128];
			GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "%s", sendername);
			strmid(wstring, string, 0, strlen(string), 255);
	        if(strcmp(FamilyInfo[family][FamilyLeader],wstring, true ) == 0 )
			{
			    new x_nr[256];
				x_nr = strtok(cmdtext, idx);
				if(!strlen(x_nr)) {
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /adjust [name]");
					SendClientMessage(playerid, COLOR_WHITE, "Available Names: Name, MOTD, Spawn, Invite, Uninvite, Rank");
					return 1;
				}
			    if(strcmp(x_nr,"name",true) == 0)
				{
				    new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[64];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /adjust Name [Family Name]");
						return 1;
					}
					strmid(FamilyInfo[family][FamilyName], result, 0, strlen(result), 255);
					SaveFamilies();
				    SendClientMessage(playerid, COLOR_WHITE, "You've adjusted your Family's Name.");
				}
				else if(strcmp(x_nr,"motd",true) == 0)
				{
				    new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[64];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /adjust MOTD [Family MOTD Text]");
						return 1;
					}
					strmid(FamilyInfo[family][FamilyMOTD], result, 0, strlen(result), 255);
					SaveFamilies();
				    SendClientMessage(playerid, COLOR_WHITE, "You've adjusted your Family's MOTD.");
				}
				else if(strcmp(x_nr,"spawn",true) == 0)
				{
				    GetPlayerPos(playerid, FamilyInfo[family][FamilySpawn][0],FamilyInfo[family][FamilySpawn][1],FamilyInfo[family][FamilySpawn][2]);
				    GetPlayerFacingAngle(playerid, FamilyInfo[family][FamilySpawn][3]);
				    FamilyInfo[family][FamilyInterior] = GetPlayerInterior(playerid);
				    SaveFamilies();
				    SendClientMessage(playerid, COLOR_WHITE, "You've adjusted your Family's Spawnplace.");
				}
				else if(strcmp(x_nr,"invite",true) == 0)
				{
				    if(FamilyInfo[family][FamilyMembers] >= 50)
				    {
				        SendClientMessage(playerid, COLOR_GREY, "   Your Family has reached the Maximum of 50 Family Members, can't invite more !");
				        return 1;
				    }
					tmp = strtok(cmdtext, idx);
					if(!strlen(x_nr)) {
					    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /adjust invite [playerid/PartOfName]");
					    return 1;
					}
					giveplayerid = ReturnUser(tmp);
					if(IsPlayerConnected(giveplayerid))
					{
					    if(giveplayerid != INVALID_PLAYER_ID)
					    {
					        if(PlayerInfo[giveplayerid][pFMember] != 255)
					        {
					            SendClientMessage(playerid, COLOR_GREY, "   That player is already in a Family !");
					            return 1;
					        }
					        GetPlayerName(playerid, sendername, sizeof(sendername));
					        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					        format(string, sizeof(string), "* You've invited %s to join '%s'.",giveplayer, FamilyInfo[family][FamilyName]);
					        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
					        format(string, sizeof(string), "* %s has invited you to join '%s', you are now a Member of it.",sendername, FamilyInfo[family][FamilyName]);
					        SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
					        PlayerInfo[giveplayerid][pFMember] = family;
					        PlayerInfo[giveplayerid][pRank] = 1;
					        FamilyInfo[family][FamilyMembers] ++;
					        SaveFamilies();
					        return 1;
					    }
					}
					else
					{
					    SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
					    return 1;
					}
				}
				else if(strcmp(x_nr,"uninvite",true) == 0)
				{
				    tmp = strtok(cmdtext, idx);
					if(!strlen(x_nr)) {
					    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /adjust uninvite [playerid/PartOfName]");
					    return 1;
					}
					giveplayerid = ReturnUser(tmp);
					if(IsPlayerConnected(giveplayerid))
					{
					    if(giveplayerid != INVALID_PLAYER_ID)
					    {
					        if(PlayerInfo[giveplayerid][pFMember] != family)
					        {
					            SendClientMessage(playerid, COLOR_GREY, "   That player is not in your Family !");
					            return 1;
					        }
					        GetPlayerName(playerid, sendername, sizeof(sendername));
					        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					        format(string, sizeof(string), "* You've kicked %s out of your Family.",giveplayer);
					        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
					        format(string, sizeof(string), "* Family Leader %s has kicked your out of the Family.",sendername);
					        SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
					        PlayerInfo[giveplayerid][pFMember] = 255;
					        PlayerInfo[giveplayerid][pRank] = 0;
					        FamilyInfo[family][FamilyMembers] --;
					        SaveFamilies();
					        return 1;
					    }
					}
					else
					{
					    SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
					    return 1;
					}
				}
				else if(strcmp(x_nr,"rank",true) == 0)
				{
				    tmp = strtok(cmdtext, idx);
					if(!strlen(x_nr)) {
					    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /adjust rank [RankNr] [playerid/PartOfName]");
					    return 1;
					}
					new rank = strval(tmp);
					if(rank < 1 || rank > 6) { SendClientMessage(playerid, COLOR_GREY, "   RankNr can't be below 1 or above 6 !"); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(x_nr)) {
					    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /adjust rank [RankNr] [playerid/PartOfName]");
					    return 1;
					}
					giveplayerid = ReturnUser(tmp);
					if(IsPlayerConnected(giveplayerid))
					{
					    if(giveplayerid != INVALID_PLAYER_ID)
					    {
					        if(PlayerInfo[giveplayerid][pFMember] != family)
					        {
					            SendClientMessage(playerid, COLOR_GREY, "   That player is not in your Family !");
					            return 1;
					        }
					        GetPlayerName(playerid, sendername, sizeof(sendername));
					        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					        format(string, sizeof(string), "* You've given %s Rank %d.",giveplayer,rank);
					        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
					        format(string, sizeof(string), "* Family Leader %s has given you Rank %d.",sendername,rank);
					        SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
					        PlayerInfo[giveplayerid][pRank] = rank;
					        return 1;
					    }
					}
					else
					{
					    SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
					    return 1;
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "   Invalid Adjust name !");
				    return 1;
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "   You are not the Leader of your Family !");
			    return 1;
			}
	    }
	    return 1;
	}
I hope anyone can help me.

Here is the pastebin link incase it's needed;
http://pastebin.com/c9yyKv40
Reply
#2

Can anyone help me with this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)