Help with /enter /exit
#1

if(!strcmp(cmdtext, "/enter", true, 1))
{
IsPlayerInRangeOfPoint(playerid, 290.7193,-1618.0544,33.1547,179.7500);
SetPlayerPos(playerid, 288.745971,169.350997,1007.171875);
SetPlayerInterior(playerid, 3);
}
else if(!strcmp(cmdtext, "/enter", true, 1))
{
SendClientMessage(playerid, COLOR_YELLOW, "You can't enter here!");
return 1;
}

if(!strcmp(cmdtext, "/exit", true, 1))
{
IsPlayerInRangeOfPoint(playerid, 288.745971,169.350997,1007.171875);
SetPlayerPos(playerid, 290.4770,-1616.1808,33.1565);
SetPlayerInterior(playerid, 0);
return 1;
}


I scripted this myself, but it keeps coming up Server: Unknown command. And if I do /anything (anything as in any non scripted commands), it takes me to the /enter point.. help
Reply
#2

Your code makes no sense at all, I seriously suggest you start reading the PAWN documentation over at CompuPhase's website section for PAWN.

First of all, you're comparing two arrays and specifying a length of 1, so basically all you're doing is checking for / and then that piece of code will run, why specify a length at all? Then your IsPlayerInRangeOfPoint is doing absolutely nothing, it's just sitting there, then you have an else if statement which can never be reached because it's the exact same check as the first if statement in that structure.

Here is an example of fixed code:

pawn Код:
if(!strcmp(cmdtext, "/enter", true))
{
    if(IsPlayerInRangeOfPoint(playerid, 290.7193,-1618.0544,33.1547,179.7500))
    {
        SetPlayerPos(playerid, 288.745971,169.350997,1007.171875);
        SetPlayerInterior(playerid, 3);
    }
    else SendClientMessage(playerid, COLOR_YELLOW, "You can't enter");
}
Now you should be able to figure out the rest for yourself, but like I said earlier, start learning PAWN and basic programming first.
Reply
#3

Код:
  if (strcmp(cmdtext, "/enter", true, 6) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, 290.7193,-1618.0544,33.1547))
            {
                SetPlayerPos(playerid, 288.745971,169.350997,1007.171875);
                SetPlayerInterior(playerid, 3);
                return 1;
            }
	 		}

 	if (strcmp(cmdtext, "/exit", true, 6) == 0)
    		{
        if(IsPlayerInRangeOfPoint(playerid, 10, 288.745971,169.350997,1007.171875))
            {
                SetPlayerPos(playerid, 288.745971,169.350997,1007.171875);
                SetPlayerInterior(playerid, 0);
                return 1;
            }
    }
Why won't /exit work in this script?
Reply
#4

You keep specifying a length in strcmp, why?

Also your code is still messy and needs to be seriously cleaned, look at this cleaner example:

pawn Код:
if (strcmp(cmdtext, "/enter", true) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 290.7193,-1618.0544,33.1547))
    {
        SetPlayerPos(playerid, 288.745971,169.350997,1007.171875);
        SetPlayerInterior(playerid, 3);
    }
    return 1;
}

if (strcmp(cmdtext, "/exit", true) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 288.745971,169.350997,1007.171875))
    {
        SetPlayerPos(playerid, 288.745971,169.350997,1007.171875);
        SetPlayerInterior(playerid, 0);
    }
    return 1;
}
The reason it wasn't working is because you're telling strcmp (string compare) to match 6 cells in cmdtext with "/exit", when exist is only 5 characters and will never match with the cmdtext.

Like I said before, I don't see why you are specifying a length at all.
Reply
#5

Код:
if (strcmp(cmdtext, "/enter", true) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 290.7193,-1618.0544,33.1547))
    {
        SetPlayerPos(playerid, 288.745971,169.350997,1007.171875);
        SetPlayerInterior(playerid, 3);
    }
    return 1;
}

if (strcmp(cmdtext, "/exit", true) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 288.745971,169.350997,1007.171875))
    {
        SetPlayerPos(playerid, 290.7193,-1618.0544,33.1547);
        SetPlayerInterior(playerid, 0);
    }
    return 1;
}
It's now this, but /exit still won't work, it doesn't say unknown command, just doesn't teleport me out. And I get an error when joining the server (S007: Exception 0xC0000005 at 4CA013) but this doesn't make me crash. Help
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)