Command for faction
#1

Hi guys.
I am busy with making a faction script, not like gteam but something else.
I have now this:
Код:
 if(strcmp(cmd, "/groveleader", true)==0)
	{
        if(adminlevel[playerid] >=3)
        {
        	tmp = strtok(cmdtext, idx);
        	if(!strlen(tmp))
        	{
                SendClientMessage(playerid, 0xFF0000AA, "Gebruik: /groveleader [id]");
                return 1;  //Stopt het commando
        	}
        	giveplayerid = strval(tmp);
        	if(!IsPlayerConnected(giveplayerid))
        	{
                SendClientMessage(playerid, 0xFF0000AA, "Speler is niet online"); return 1;
        	}
			grove[giveplayerid] = 10;
			SendClientMessage(playerid, 0x00FF00AA, "Deze speler heeft nu grove level 10");
        	SendClientMessage(giveplayerid, 0xFF0000AA, "Je bent nu grove level 10");
		}
		else
		{
			SendClientMessage(playerid,COLOR_RED,"Je mag dit niet doen");
		}
        return 1;
	}
This is only for grove
So when you have 12 gangs or something you have 12 commands
It would be better when this is one command.
I was thinking something like /setleader (playerid) (grove/...)
Further I have these command

Код:
if(strcmp(cmd,"/grovepromote", true) == 0)
		{
		if(grove[giveplayerid] >= 1)
			{
	  		new name [MAX_PLAYER_NAME];
	   		tmp = strtok(cmdtext, idx);
	   		if(!strlen(tmp))
	   		return SendClientMessage(playerid, 0xE3E3E3FF, "USAGE: /grovepromote [playerid]");
	   		giveplayerid = strval(tmp);
	   		if(IsPlayerConnected(giveplayerid))
	   		if(grove[giveplayerid] >= 1)
		   	{
				{
				if(grove[playerid] >= 9) {

				grove[giveplayerid] += 1;
				GetPlayerName(playerid, name, sizeof(name));
				format(string, sizeof(string), "%s heeft je gepromote naar een hoger grove level", name);
				SendClientMessage(giveplayerid,0xE3E3E3FF,string);
				format(string, sizeof(string), "je grove level is nu %d", grove);
				SendClientMessage(playerid,0xE3E3E3FF,string);


				GetPlayerName(giveplayerid, name, sizeof(name));
				format(string, sizeof(string), "Je hebt %s gepromote tot een hoger grove level", name);
				SendClientMessage(playerid,0xE3E3E3FF,string);
				format(string, sizeof(string), "Hij is nu grove level %d", grove);
				SendClientMessage(playerid,0xE3E3E3FF,string);
				}
				else
				{
					SendClientMessage(playerid,0xE3E3E3FF,"Je mag dit niet doen");
				}
	 		}
	 	}
		}

	   return 1;
	}

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

	  	new name [MAX_PLAYER_NAME];
	   	tmp = strtok(cmdtext, idx);
	   	if(!strlen(tmp))
	   	return SendClientMessage(playerid, 0xE3E3E3FF, "USAGE: /grovedemote [playerid]");
	   	giveplayerid = strval(tmp);
	   	if(IsPlayerConnected(giveplayerid))
	   	if(grove[giveplayerid] >= 1) {
		{
		if(grove[playerid] >= 9) {

		grove[giveplayerid] -= 1;
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "%s heeft je gedemote naar een lager grove level", name);
		SendClientMessage(giveplayerid,0xE3E3E3FF,string);
		format(string, sizeof(string), "je grove level is nu %d", grove);
		SendClientMessage(playerid,0xE3E3E3FF,string);


		GetPlayerName(giveplayerid, name, sizeof(name));
		format(string, sizeof(string), "Je hebt %s gedemote tot een lager grove level", name);
		SendClientMessage(playerid,0xE3E3E3FF,string);
		format(string, sizeof(string), "Hij is nu grove level %d", grove);
		SendClientMessage(playerid,0xE3E3E3FF,string);
		}
		else
		{
		SendClientMessage(playerid,0xE3E3E3FF,"Je mag dit niet doen");
		}
		}
		}
	   	return 1;
	}
Maybe this could also be one command for more gangs?

1: I am sorry but i don't know how to put this nicely in such a dialog or something the script
2: I thought that this was good under scripting discussion if not, sorry.
Reply
#2

Yes you could just do the same as now and create a balla[MAX_PLAYERS] or something and the command exactly the same only everything with balla[playerid] / balla[giveplayerid]
Reply
#3

No look what I want is not 100000 commands for 12 factions.
I would like to make a command like
/setteam (playerid) (sapd/ballas/grove/everything)
I looked to the tutorial but did not get it.
Reply
#4

Ik denk dat dit gaat werken (kunnen foutjes in zitten)

pawn Код:
//top
#define TEAM_NONE 0
#define TEAM_BALLAS 1
#define TEAM_GROVE 2
#define TEAM_SAPD 3
//top
new Team[MAX_PLAYERS];
//-----------
public OnPlayerConnect(playerid)
{
   Team[playerid] = TEAM_NONE;
}
pawn Код:
if(!strcmp(cmd, "/setteam", true))
{
   new tmp[256], tmp2[256], idx;
   tmp = strtok(cmdtext, idx);
   if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "Gebruik: /setteam [playerid] [team]");
   tmp2 = strtok(cmdtext, idx);
   if(!strlen(tmp2)) return SendClientMessage(playerid, 0xFF0000AA, "Gebruik: /setteam [playerid] [team]");
   new giveplayerid = strval(tmp);
   new team = strval(tmp2);
   if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, 0xFF0000AA, "Die speler is niet online!");
   new teamid;
   if(!strcmp(team, "grove", true)) { teamid = TEAM_GROVE; }
   if(!strcmp(team,"ballas",true)) { teamid = TEAM_BALLAS; }
   if(!strcmp(team, "sapd", true)) { teamid = TEAM_SAPD; }
   {
      team[giveplayerid] = teamid;
      SendClientMessage(playerid, 0xFF0000AA, "Team gezet!");
   } else return SendClientMessage(playerid, 0xFF0000AA, "Dat team bestaat niet!");
   return 1;
}
Reply
#5

I tried it
Super bedankt man
I am sorry maybe it is noob action or something but I now got this:

Код:
if(!strcmp(cmd, "/setteam", true))
	{
   		tmp = strtok(cmdtext, idx);
   		if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "Gebruik: /setteam [playerid] [team]");
   		tmp2 = strtok(cmdtext, idx);
   		if(!strlen(tmp2)) return SendClientMessage(playerid, 0xFF0000AA, "Gebruik: /setteam [playerid] [team]");
   		new team = strval(tmp2);
   		if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, 0xFF0000AA, "Die speler is niet online!");
   		new teamid;
   		if(!strcmp(team, "grove", true)) { teamid = TEAM_GROVE; }
   		if(!strcmp(team,"ballas",true)) { teamid = TEAM_BALLAS; }
   		if(!strcmp(team, "sapd", true)) { teamid = TEAM_SAPD; }
   		{
      		team[giveplayerid] = teamid
      		SendClientMessage(playerid, 0xFF0000AA, "Team gezet!");
   		}
 		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "Dat team bestaat niet!");
		}
   		return 1;
	}
(i have removed some news because I all ready had them

I get now these errors:
D:\joram server\gamemodes\Dutchlife.pwn(146 : error 035: argument type mismatch (argument 1)
D:\joram server\gamemodes\Dutchlife.pwn(1469) : error 035: argument type mismatch (argument 1)
D:\joram server\gamemodes\Dutchlife.pwn(1470) : error 035: argument type mismatch (argument 1)
D:\joram server\gamemodes\Dutchlife.pwn(1472) : error 028: invalid subscript (not an array or too many subscripts): "team"
D:\joram server\gamemodes\Dutchlife.pwn(1472) : warning 215: expression has no effect
D:\joram server\gamemodes\Dutchlife.pwn(1472) : error 001: expected token: ";", but found "]"
D:\joram server\gamemodes\Dutchlife.pwn(1472) : error 029: invalid expression, assumed zero
D:\joram server\gamemodes\Dutchlife.pwn(1472) : fatal error 107: too many error messages on one line

1468-1470 are these lines with if strcm... grove
1472 is the line of team(giveplayerid) = teamid
Reply
#6

pawn Код:
if(!strcmp(cmd, "/setteam", true))
{
    tmp = strtok(cmdtext, idx); //get the playerid as a string
    if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "Gebruik: /setteam [playerid] [team]");
   
    new giveplayerid = strval(tmp); //transforming the string into a number
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, 0xFF0000AA, "Die speler is niet online!");
   
    tmp = strtok(cmdtext, idx); //getting the team
    if(!strlen(tmp2)) return SendClientMessage(playerid, 0xFF0000AA, "Gebruik: /setteam [playerid] [team]");
   
    new teamid;
    if(!strcmp(tmp, "grove", true)) { teamid = TEAM_GROVE; }
    else if(!strcmp(tmp,"ballas",true)) { teamid = TEAM_BALLAS; }
    else if(!strcmp(tmp, "sapd", true)) { teamid = TEAM_SAPD; }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Dat team bestaat niet!");
        return 1;
    }
   
    team[giveplayerid] = teamid
    SendClientMessage(playerid, 0xFF0000AA, "Team gezet!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)