SA-MP Forums Archive
Function [+REP] - 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: Function [+REP] (/showthread.php?tid=593287)



Function [+REP] - Alpha000 - 03.11.2015

Hello Everyone i want to create a Function which checks that if a player is at land..

This is My command by which I can edit Land:

PHP код:
CMD:lands(playeridparams[])
{
    new 
playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    for(new 
xMAX_LANDSx++)
    {
        if([
COLOR=Red"]""""""""""[/COLOR](playerid, LandInfo[x][landZone]))
        {
               if(strcmp(playername, LandInfo[x][landOwner], true) == 0)
            {
                editingLand[playerid] = x;
                break;
            }
            else
            {
                editingLand[playerid] = -1;
            }
        }
    }
    ShowPlayerDialogEx(playerid, LANDSMAIN,DIALOG_STYLE_LIST, "
Lands Select an option", "Toggle Lands on Map\nBuild\nEdit a Building\nDestroy a Building\nBuy Land\nSell Land\nDestroy all objects", "Select", "Cancel");
    return 1;

There at """"""" (red Colored) I want to create a Function which checks that if a player is in its land and if the player is not in land it should show player message that You are not in your Land, and if the player is in its land boundaries then it should allow player to edit land.

Necessary Info:

Код:
        Float: landMinX,
	Float: landMinY,
	Float: landMaxX,
	Float: landMaxY,
        landZone



Re: Function [+REP] - SecretBoss - 03.11.2015

It can be done with IsPlayerInRangeOfPoint, I can make it but I don't know your coordinate variables


Re: Function [+REP] - Alpha000 - 03.11.2015

coordinates that why i cant make it... there are no coordinates, we just have to make land in game which is not a point. It has 4 boundaries (east, west, north, south) and i want to make a function that checks if a player is in that boundary.


Re: Function [+REP] - SecretBoss - 03.11.2015

Quote:
Originally Posted by Alpha000
Посмотреть сообщение
coordinates that why i cant make it... there are no coordinates, we just have to make land in game which is not a point. It has 4 boundaries (east, west, north, south) and i want to make a function that checks if a player is in that boundary.
You can't detect if player is in boundaries, but you can only set boundaries

How exactly your system is working?


Re: Function [+REP] - Alpha000 - 03.11.2015

You must have seen land system in lawless RP... mine is like that but i have no idea that how can i check if a player is in his land... Otherwise player can make land objects everywhere.


Re: Function [+REP] - ThePhenix - 03.11.2015

You can use:
https://sampwiki.blast.hk/wiki/SetPlayerWorldBounds

To limit a player to a certain area.

And you can also use:

PHP код:
IsPlayerInArea(playeridFloat:MinXFloat:MinYFloat:MaxXFloat:MaxY)
{
    new 
Float:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    if(
>= MinX && <= MaxX && >= MinY && <= MaxY) {
        return 
1;
    }
    return 
0;

To check if the player is inside his land.


Re: Function [+REP] - Alpha000 - 03.11.2015

i have a question....
Is there any way by which i can set player to stay in land boundaries...like in SetPlayerWorldBounds i have to set boundaries but i want to set his land boundaries instead of adding coordinates. like my land boundaries are Float: landMinX,
Float: landMinY,
Float: landMaxX,
Float: landMaxY,


Re: Function [+REP] - Crayder - 03.11.2015

You aren't making much sense. That's precisely what SetPlayerWorldBounds does. I personally don't like that function though.