1 command available
#1

hey is there a way when i can do like
m4w = 1
or
sw = 1
then i can only type the /leave command(so i cant use commands like /heal, /respawn etc..)

i can show you what i have made so far.

Код:
if (strcmp("/leave", cmdtext, true, 10) == 0)
	{
		if(m4w[playerid] == 1)
		{
		SpawnPlayer(playerid);
		ResetPlayerWeapons(playerid);
		SetPlayerInterior(playerid, 1);
		sw[playerid] = 0;
		m4w[playerid] = 0;
		SetPlayerPos(playerid, 292.8136,-35.3702,1001.5156);
		return 1;
		}
		else
		if(sw[playerid] == 1)
		{
		SpawnPlayer(playerid);
		ResetPlayerWeapons(playerid);
		SetPlayerInterior(playerid, 1);
		sw[playerid] = 0;
		m4w[playerid] = 0;
		SetPlayerPos(playerid, 292.8136,-35.3702,1001.5156);
		return 1;
		}
		else
		{
		SendClientMessage(playerid, COLOR_NORMALRED, "You can only use this command while in war");
		return 1;
		}
	}
thx for your help
Reply
#2

you can't use which commands? All the commands?
Reply
#3

You'd have to add

pawn Код:
if(m4w[playerid] == 1 || sw[playerid] == 1) return SendClientMessage(playerid, COLOR_NORMALRED, "You cannot use this command while in war."); //I'm assuming this is the message you want.
on the top of the commands you would like to be "disabled" while your variable is active.
Reply
#4

Roomeo can you read? that's not his question.

Anyway you can use something like this:
pawn Код:
new IsInDM[MAX_PLAYERS] = 0; //Creating variable...
if (strcmp("/deathmatch", cmdtext, true, 10) == 0)
{
    IsInDM[playerid] = 1;//Sets the variable to 1 so he cannot leave
}
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
    if(IsInDM[playerid] == 1) return SendClientMessage(playerid, COLOR, "Uhm..you're in deathmatch");
    SetPlayerHealth(playerid, 100);//Sets the players health to 100 if he is NOT in a DM zone
}
Reply
#5

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
Roomeo can you read? that's not his question.

Anyway you can use something like this:
pawn Код:
new IsInDM[MAX_PLAYERS] = 0; //Creating variable...
if (strcmp("/deathmatch", cmdtext, true, 10) == 0)
{
    IsInDM[playerid] = 1;//Sets the variable to 1 so he cannot leave
}
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
    if(IsInDM[playerid] == 1) return SendClientMessage(playerid, COLOR, "Uhm..you're in deathmatch");
    SetPlayerHealth(playerid, 100);//Sets the players health to 100 if he is NOT in a DM zone
}
hmm i thougth there was a easier way because then i have to set that IF in all my commands :S, and that would make my script to long, i have to hold it to minimum lines to make it work faster
Reply
#6

If its possible
Reply
#7

It's possible, if you want 1 command avaible..

pawn Код:
public OnPlayerComandText(...)
{
    if(m4w[playerid] == 1 || sw[playerid] == 1) return SendClientMessage(playerid,color,"You're in m4w and sw and you cant use commands!");
}
Reply
#8

Quote:
Originally Posted by Marricio
Посмотреть сообщение
It's possible, if you want 1 command avaible..

pawn Код:
public OnPlayerComandText(...)
{
    if(m4w[playerid] == 1 || sw[playerid] == 1) return SendClientMessage(playerid,color,"You're in m4w and sw and you cant use commands!");
}
but i still want it to be possible to write a /leave command in there ?
Reply
#9

Quote:
Originally Posted by Marricio
Посмотреть сообщение
It's possible, if you want 1 command avaible..

pawn Код:
public OnPlayerComandText(...)
{
    if(m4w[playerid] == 1 || sw[playerid] == 1) return SendClientMessage(playerid,color,"You're in m4w and sw and you cant use commands!");
}
well i did not get that to work i did like this:
Код:
if(m4w[playerid] == 1 || sw[playerid] == 1)
    {
	SendClientMessage(playerid,COLOR_NORMALRED,"You are in war and can not use any commands");
	return 1;
	}
	else
	if (strcmp("/leave", cmdtext, true, 10) == 0)
	{
		if(m4w[playerid] == 1)
		{
		SpawnPlayer(playerid);
		ResetPlayerWeapons(playerid);
		SetPlayerInterior(playerid, 1);
		sw[playerid] = 0;
		m4w[playerid] = 0;
		SetPlayerPos(playerid, 292.8136,-35.3702,1001.5156);
		return 1;
		}
		else
		if(sw[playerid] == 1)
		{
		SpawnPlayer(playerid);
		ResetPlayerWeapons(playerid);
		SetPlayerInterior(playerid, 1);
		sw[playerid] = 0;
		m4w[playerid] = 0;
		SetPlayerPos(playerid, 292.8136,-35.3702,1001.5156);
		return 1;
		}
		else
		{
		SendClientMessage(playerid, COLOR_NORMALRED, "You can only use this command while in war");
		return 1;
		}
	}
what i want this to do is:
1. you can only type the /leave command when sw = 1 or m4w = 1
2. you can't type other commands than /leave when sw = 1 or m4w = 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)