SA-MP Forums Archive
[QUESTION] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [QUESTION] (/showthread.php?tid=315458)



[QUESTION] - KiiD - 03.02.2012

First: I wanna know how I can make a command work in only the X, Y, Z coordinates I set it to.
Second: I wanna set commands only in a certain area I select, or maybe the whole area of a shop? once I can make shops I will need this feature so first things first, what do I do now? (Regarding the first question)

-----------------------------------------------------------------------------------------

What you said did help, but I've hit another problem with this code. Help?
I Think I'm Doing Something Wrong, Can Anyone Correct The Code For Me?

My Code:
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/enter, true))	{
	{
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 1154.5475, -1457.7513, 15.7969))
	{
	SetPlayerPos(playerid, -25.884498,-185.868988,1003.546875);
	{
	SendClientMessage(playerid, 0xFFFFFFFF, "You Are Not Outside A 24/7");
{
	return 1;
}
The Errors I Get:
Code:
D:\khubb2\Desktop\SAMP\Blank Server\gamemodes\PROJECT.pwn(137) : warning 217: loose indentation
D:\khubb2\Desktop\SAMP\Blank Server\gamemodes\PROJECT.pwn(140) : error 030: compound statement not closed at the end of file (started at line 136)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
-------------------------------------------------------------------------------------------------------

See Page 2+ For My New Errors I Need Help With, THANKS!


Respuesta: [QUESTION] - junkbuster - 03.02.2012

IsPlayerInRangeOfPoint

About this?


Re: [QUESTION] - Mark™ - 03.02.2012

read wiki, it will surely help.


Re: [QUESTION] - KiiD - 03.02.2012

Hmm, could someone give me an example? What I'm trying isnt working.


Re: [QUESTION] - MasterJoker - 03.02.2012

pawn Code:
CMD:checktest(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 1.0, /* Replace your coordinates */))
    {
          //codes here
    }
    else
    {
         //else if player is not in the area
    }
    return 1;
}



Re: [QUESTION] - [XST]O_x - 03.02.2012

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/example"))
    {
        new Float:p_Pos[3]; GetPlayerPos(playerid,p_Pos[0],p_Pos[1],p_Pos[2]);
        if( (p_Pos[0] == /* The X pos*/) && (p_Pos[1] == /*The Y pos*/) && (p_Pos[2] == /*The Z pos*/) )
        {
            //Command applys here.
        }
        else SendClientMessage(playerid,-1,"You're not in the correct positions!");
        return 1;
    }
    return 0;
}
But to be in the exact position you need to be pretty damn accurate.


Respuesta: [QUESTION] - junkbuster - 03.02.2012

For example a command using zcmd.

pawn Code:
CMD:buycrack(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid,2.0, x, y, z) ) // Your coordinates
    {
        SendClientMessage(playerid, "You have purchased a bag of crack.");
    }
    return 1;
}



Re: [QUESTION] - KiiD - 03.02.2012

thanks for the help guys


Re: [QUESTION] - KiiD - 04.02.2012

I Think I'm Doing Something Wrong, Can Anyone Correct The Code For Me?

My Code:
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/enter, true))	{
	{
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 1154.5475, -1457.7513, 15.7969))
	{
	SetPlayerPos(playerid, -25.884498,-185.868988,1003.546875);
	{
	SendClientMessage(playerid, 0xFFFFFFFF, "You Are Not Outside A 24/7");
{
	return 1;
}
The Errors I Get:
Code:
D:\khubb2\Desktop\SAMP\Blank Server\gamemodes\PROJECT.pwn(137) : warning 217: loose indentation
D:\khubb2\Desktop\SAMP\Blank Server\gamemodes\PROJECT.pwn(140) : error 030: compound statement not closed at the end of file (started at line 136)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: [QUESTION] - Amit_B - 04.02.2012

Yeah, your syntax is wrong.
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/enter", true))
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.0, 1154.5475, -1457.7513, 15.7969))
        {
            SetPlayerPos(playerid, -25.884498,-185.868988,1003.546875);
        }
        else
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "You Are Not Outside A 24/7");
        }
        return 1;
    }
}
Notice the { }!
Also notice that you've used "/enter" and not "/enter in the command name.

Quote:
Originally Posted by [XST]O_x
View Post
pawn Code:
...
But to be in the exact position you need to be pretty damn accurate.
Almost impossible, pointless to try.