Allow commands on certain place/after another command
#1

Hello

I got a command called /stuntarea , that teleports you to a certain place.Now , when i type this i want the players to have access to some commands , like "/s" to save position , "/l" to load position , and "/nrg" to spawn a nrg , but ONLY after you are teleported to the area , and when you quit the area (by typing /deathmatcharea , or /safearea) , the players CANNOT use these commands anymore

Is this possible ?
Reply
#2

Use a bool and set it to true upon joining the area and to false upon leaving the area.

pawn Код:
new bool:area;
Reply
#3

How can i set it to true/false , and how this is supposed to help me ?
Reply
#4

pawn Код:
new bool:area;

/* Script which lets you enter the area ... */

area = true;

/* Script which lets you leave the area ... */

area = false;

/* Whenever you're scripting a command that should only be useable in the area use the
following: */


if(area != true)
{
   SendClientMessage(playerid, COLOR, "You are not able to use this command.");
}
Reply
#5

You will need a variable for every player actually.

pawn Код:
new bool:isinarea[MAX_PLAYERS] = false;

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/stuntarea"))
    {
        isinarea[playerid] = true;
        SetPlayerPos(//...);
        //...
        return 1;
    }
    if(!strcmp(cmdtext,"/deathmatcharea"))
    {
        isinarea[playerid] = false;
        //....
        return 1;
    }
    if(!strcmp(cmdtext, "/safearea"))
    {
        isinarea[playerid] = false;
        //....
        return 1;
    }
   
    //And the command with the term:
    if(!strcmp(cmdtext,"/command"))
    {
        if(isinarea[playerid] == true)
        {
            //....
        }
        else return SendClientMessage(playerid, -1, "You are not allowed to use that command! Please use /stuntarea first!");
    }
    return 0;
}
Reply
#6

If i do exaclty what XST says , i got 4 errors :

C:\Documents and Settings\HP_Administrateur\Bureau\Nouveau dossier\SAMP server\gamemodes\test.pwn(397) : error 029: invalid expression, assumed zero
C:\Documents and Settings\HP_Administrateur\Bureau\Nouveau dossier\SAMP server\gamemodes\test.pwn(397) : error 029: invalid expression, assumed zero
C:\Documents and Settings\HP_Administrateur\Bureau\Nouveau dossier\SAMP server\gamemodes\test.pwn(397) : warning 215: expression has no effect
C:\Documents and Settings\HP_Administrateur\Bureau\Nouveau dossier\SAMP server\gamemodes\test.pwn(397) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\HP_Administrateur\Bureau\Nouveau dossier\SAMP server\gamemodes\test.pwn(397) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Here is my script , maybe i did something wrong :
Код:
new bool:isinarea[MAX_PLAYERS] = false;

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
		SetPlayerHealth(playerid, 0);
		SendClientMessage(playerid, COLOR_YELLOW, "You commited a suicide...For Shame!");
		return 1;
	}
	if (strcmp("/deathmatch", cmdtext, true, 10) == 0)
	{
	    if(GetPlayerSkin(playerid) == 1)
	    {
	    	GivePlayerWeapon(playerid, 22, 60);
	    	GivePlayerWeapon(playerid, 29, 120);
		}
  		if(GetPlayerSkin(playerid) == 2)
	    {
	    	GivePlayerWeapon(playerid, 24, 80);
	    	GivePlayerWeapon(playerid, 26, 25);
	    	GivePlayerWeapon(playerid, 33, 15);
		}
		if(GetPlayerSkin(playerid) == 3)
	    {
	    	GivePlayerWeapon(playerid, 23, 120);
	    	GivePlayerWeapon(playerid, 25, 40);
	    	GivePlayerWeapon(playerid, 22, 80);
		}
		if(GetPlayerSkin(playerid) == 4)
	    {
	    	GivePlayerWeapon(playerid, 5, 0);
	    	GivePlayerWeapon(playerid, 28, 305);
	    	GivePlayerWeapon(playerid, 23, 50);
		}
		if(GetPlayerSkin(playerid) == 5)
	    {
	    	GivePlayerWeapon(playerid, 25, 10);
	    	GivePlayerWeapon(playerid, 30, 100);
	    	GivePlayerWeapon(playerid, 24, 35);
		}
		if(GetPlayerSkin(playerid) == 6)
     	{
	    	GivePlayerWeapon(playerid, 24, 80);
	    	GivePlayerWeapon(playerid, 26, 25);
	    	GivePlayerWeapon(playerid, 33, 15);
		}
		if(GetPlayerSkin(playerid) == 7)
     	{
	    	GivePlayerWeapon(playerid, 22, 100);
	    	GivePlayerWeapon(playerid, 29, 120);
		}
		if(GetPlayerSkin(playerid) == 8)
     	{
	    	GivePlayerWeapon(playerid, 25, 10);
	    	GivePlayerWeapon(playerid, 30, 100);
	    	GivePlayerWeapon(playerid, 24, 35);
		}
		if(GetPlayerSkin(playerid) == 9)
     	{
	    	GivePlayerWeapon(playerid, 24, 80);
	    	GivePlayerWeapon(playerid, 26, 25);
	    	GivePlayerWeapon(playerid, 33, 15);
		}
		if(GetPlayerSkin(playerid) == 10)
     	{
	    	GivePlayerWeapon(playerid, 23, 120);
	    	GivePlayerWeapon(playerid, 25, 40);
	    	GivePlayerWeapon(playerid, 22, 80);
		}
		isinarea[playerid] = false;
	    SetPlayerHealth(playerid, 99);
		SetPlayerPos(playerid, 982.3617,-1416.5402,13.2676);
		SendClientMessage(playerid, COLOR_GREEN, "You have been teleported to the Deathmatch Area!");
		return 1;
	}
	if (strcmp("/safearea", cmdtext, true, 10) == 0)
	{
	    isinarea[playerid] = false;
	    SetPlayerHealth(playerid, 99)
		ResetPlayerWeapons(playerid);
		SetPlayerPos(playerid, 691.4066,-583.6253,16.3281);
		SendClientMessage(playerid, COLOR_GREEN, "You have been teleported to the Safe Area!");
		return 1;
	}
	if (strcmp("/stuntarea", cmdtext, true, 10) == 0)
	{
	    isinarea[playerid] = true;
		SetPlayerHealth(playerid, INFINITY);
		ResetPlayerWeapons(playerid);
		SetPlayerPos(playerid, -1302.1410,-279.3289,14.1484);
		SendClientMessage(playerid, COLOR_GREEN, "You have been teleported to the Stunt Area!");
		return 1;
	}
	if (strcmp("/help", cmdtext, true, 10) == 0)
	{
		SendClientMessage(playerid, COLOR_YELLOW, "Type /kill if you want to suicide (in case of stuck etc..)");
		SendClientMessage(playerid, COLOR_YELLOW, "Type /deathmatch to be teleported to the deathmatch area (every man for himself !)");
		SendClientMessage(playerid, COLOR_YELLOW, "Type /safearea to be teleported to the safe area (you can replish health , ammo etc... and be ready to attack !)");
		SendClientMessage(playerid, COLOR_YELLOW, "Type /stuntarea to be teleported to the stunt area (to pratice at stunting)");
		SendClientMessage(playerid, COLOR_YELLOW, "While being at /stuntarea , type /s to save position");
		SendClientMessage(playerid, COLOR_YELLOW, "While being at /stuntarea , type /l to load position");
		SendClientMessage(playerid, COLOR_YELLOW, "While being at /stuntarea , type /nrg to spawn a NRG500");
		return 1;
	}
	if (strcmp("/s", cmdtext, true, 10) == 0)
	{
		if(isinarea[playerid] == true)
		{
  			new file[128], pname[MAX_PLAYER_NAME];
			new Float:x, Float:y, Float:z;
			GetPlayerName(playerid, pname, sizeof(pname));
			format(file, sizeof(file), "\\SavePos\\%s.ini", pname);
			if(!dini_Exists(file))
			dini_Create(file);
			GetPlayerPos(playerid, x, y, z);
			dini_FloatSet(file, "posX", x);
			dini_FloatSet(file, "posY", y);
			dini_FloatSet(file, "posZ", z);
			SendClientMessage(playerid, COLOR_YELLOW, "Your position has been saved , type /l to load it !");
		}
		else return SendClientMessage(playerid, COLOR_YELLOW, "You can only use this command in the Stunt Area!");
	 }
	 if (strcmp("/l", cmdtext, true, 10) == 0)
	 {
		if(isinarea[playerid] == true)
		{
			new file[128], pname[MAX_PLAYER_NAME];
			new Float:x, Float:y, Float:z;
			GetPlayerName(playerid, pname, sizeof(pname));
			format(file, sizeof(file), "\\SavePos\\%s.ini", pname);
			x = dini_Float(file, "posX");
			y = dini_Float(file, "posY");
			z = dini_Float(file, "posZ");
			SetPlayerPos(playerid, x, y, z);
		}
		else return SendClientMessage(playerid, COLOR_GREY, "You can only use this command in the Stunt Area!");
	 }
	 return 0;
}
Reply
#7

What's line 397?
Reply
#8

It's the "isinarea[playerid] = false;" the first one , after

if(GetPlayerSkin(playerid) == 10)
{
GivePlayerWeapon(playerid, 23, 120);
GivePlayerWeapon(playerid, 25, 40);
GivePlayerWeapon(playerid, 22, 80);
}
Reply
#9

so ?
Reply
#10

Will my script work , even with these errors ?
Can someone help me , i am confused here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)