/givekey
#1

Hi, I have a question.

On my server I have Team HQ's which require people not part of that team to have a key.

Код:
	if(strcmp(cmd, "/givekey", true) == 0 || strcmp(cmd, "/gkey", true) == 0)
	{
	  if(gTeam[playerid] == 0)
	  {
	    SendClientMessage(playerid, COLOR_RED, "You don't have any keys to give.");
	    return 1;
	  }
	  else if(gTeam[playerid] == 1)
      {
      return 1;
      }
     return 1;
     }
In the else if statement, I need the player entering the command to enter an id of a nearby player, and make the player receiving the key to get the key = to the team number.

Go gTeam = 1 gives Key = 1

Код:
new Key[MAX_PLAYERS];
- Key Variable.
Reply
#2

Here is one i quickly made. It's untested.

pawn Код:
if(!strcmp(cmd,"/givekey",true,8))
    {
        if(Key[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "You don't have any keys to give.");
            return 1;
        }
        else if(Key[playerid] == 1)
        {
            if(!strlen(cmd[8])) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /givekey [playerid]");
            new otherplayerid = strval(cmdtext[9]);
            if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "That player isnt connected");
            if(otherplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You cannot send a key to yourself!");
            new string[128], string2[128];
            new adminname[MAX_PLAYER_NAME], otherguysname[MAX_PLAYER_NAME];
            GetPlayerName(playerid,adminname,sizeof(adminname));
            GetPlayerName(otherplayerid,otherguysname,sizeof(otherguysname));
            format(string,sizeof(string),"** You have given your key to %s", otherguysname);
            format(string2,sizeof(string2),"** You have received a key from to %s", adminname);
            SendClientMessage(playerid, 0x00E100FF, string);
            SendClientMessage(otherplayerid, 0x00E100FF, string2);
            Key[otherplayerid] = 1;
            Key[playerid] = 0;
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)