Disabling commands.
#1

I have /arena1 teleport command, How do I disable commands there? (exepct /aleave?)
Reply
#2

You mean something like this?

Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
	if(IsPlayerInRangeOfPoint(playerid, r, x, y, z) && strcmp(cmdtext,"/aleave",true) != 0) //set coordinates and radius of arena
	{
	SendClientMessage(playerid, -1, "You cant use commands in arena!");
        return 0;
	}
    return 1;
}
Reply
#3

No code, Nothing to go on.


You need to find the variable (Commonly an array, but could be an enum) that depicts who is in an arena, and then put a check on all commands that you want to disable, denying the usage of it, if they are in the arena.

Quote:
Originally Posted by OptimusBloodHunter
Посмотреть сообщение
You mean something like this?
Don't suggest horrid code like that... Make an array, and use that instead of on every command usage, checking the location of the player.


And just so you know, blindly throwing up code like that really doesn't help, and is often non-working anyway. This also encourages people to simply throw up vague 'code-needed' begging, and when you answer it with shit that 'seems' to work, then when others tell them they should be submitting code, they then get all defensive because someone went and threw them code, that even if it doesn't work, it looks to them to be 'fine' because someone 'tried' to 'give' them what they 'wanted'.
Reply
#4

What if I get the player's interior and if he is in that interior then..(code here, this and that..)

Would that work?
Reply
#5

public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(IsPlayerInArena1 && strcmp(cmdtext,"/aleave",true) != 0)
{
SendClientMessage(playerid, -1, "can't use commands in arena 1");
return 0;
}
return 1;
}
Reply
#6

Interior isn't too bad, as it's a simple quick check, but if anyone else is in any interior (As many interiors share interior IDs), then that will be a problem.

If you use a player enum, simply put a variable in there. Or, if you need to, make a "IsInArena[MAX_PLAYERS]" array, and simply set it on entering the arena.

If you set it to 0 for not being in there, and 1 for being in there, then you can simply use "if(IsInArena[playerid])" as the check.

It's a lot better in checking this, as if you check the interior, it can cause trouble later on when you decide to use interiors for future things.


Another option, is to use different VirtualWorlds for the arena, then you could simply check which VW they are in.


For instance, you could have VW 0 is 'normal', VW 1 is arenas, VW2 is racing, VW3 is stunt, e.t.c.

When I look at things, I look at how it can be expanded later, rather than just doing what needs to be done 'currently'.
Reply
#7

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
What if I get the player's interior and if he is in that interior then..(code here, this and that..)

Would that work?
new PlayerInArena[MAX_PLAYERS];

OnPlayerConnect,OnPlayerSpawn,OnPlayerDeath... PlayerInArena[playerid] = 0;

In command /arena1 put PlayerInArena[playerid] = 1; and in /aleave PlayerInArena[playerid] = 0;

And than instead IsPlayerInRangeOfPoint you can use if(PlayerInArena[playerid] == 1 && ...
Reply
#8

Just stop it FFS... You explain nothing, and are simply spamming shit to either gain postcount or hoping for rep...
Reply
#9

I tried this

Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
  if(IsPlayerInArena1[playerid] && strcmp(cmdtext,"/aleave",true) != 0)
  {
	 SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You can't use commands in the arena!");
	 return 0;
  }
   return 1;
}
no errors whatsoever , but in game it has no effect
Reply
#10

Quote:
Originally Posted by rfr
Посмотреть сообщение
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(IsPlayerInArena1 && strcmp(cmdtext,"/aleave",true) != 0)
{
SendClientMessage(playerid, -1, "can't use commands in arena 1");
return 0;
}
return 1;
}
stop giving him parts of your code/
he doesnt even have isplayerinarena1 defined and you give him the code without explaining what to do.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)