YSI:Areas
From SA-MP Wiki
Contents |
Area system
Area_AddBox
This function returns the id of the area created for use in other functions and callbacks.
Area_AddBox explained
Area_AddBox(minx, miny, maxx, maxy);
you need two x and y coordinates.
You can get it to do the this:
Go in game and go to you area, the area need to be a box so the mine looks:
+-------------------------+ |------------------------2| |-------------------------| |-------------------------| |1------------------------| +-------------------------+
1 is the first corner do there /save first corner 2 is the second corner do there /save second corner
if you hold on this step for creating the Area_AddBox. There shouldn't be any problems.
Now we get that coordinates, lets going to make it.
Make an stunt area
We need some stunt objects, i've made it a little bit (working this out you need to do it on your own):
Place this in OnGameModeInit:
CreateDynamicObject(4867, 800.962646, -2158.845703, 11.832575, 0.0000, 0.0000, 179.5182); CreateDynamicObject(10838, 836.705078, -2068.730957, 27.519600, 0.0000, 0.8594, 90.1365); CreateDynamicObject(8420, 655.192810, -2106.210205, 11.866266, 0.0000, 0.0000, 0.0000); CreateDynamicObject(3864, 692.553162, -2107.581787, 17.939854, 0.0000, 0.0000, 0.0000); CreateDynamicObject(1632, 887.554321, -2111.541260, 13.007689, 0.0000, 0.0000, 274.9158); CreateDynamicObject(1632, 894.087097, -2110.857910, 18.846931, 36.0963, 0.0000, 276.8666); CreateDynamicObject(1632, 895.568115, -2110.628174, 27.436823, 75.6304, 357.4217, 282.1780); CreateDynamicObject(1632, 891.461792, -2111.281250, 35.207813, 112.5861, 0.8594, 279.2130); CreateDynamicObject(17639, 836.344299, -2115.717773, 32.487503, 0.0000, 359.1406, 4.2972); CreateDynamicObject(13592, 786.926880, -2123.485596, 41.730373, 0.0000, 0.0000, 7.8896); CreateDynamicObject(1655, 776.899048, -2127.586182, 33.365818, 3.4377, 0.0000, 87.6625); CreateDynamicObject(1655, 769.323486, -2127.369385, 37.955864, 14.6104, 0.0000, 88.5220); CreateDynamicObject(17662, 645.966553, -2149.316895, 48.979053, 358.2811, 359.1406, 86.8031); CreateDynamicObject(17639, 704.891479, -2130.325439, 43.166576, 0.0000, 0.0000, 0.0000);
So now we have some stunt objects, we going to made the area first set on top of your script the next line of code:
new StuntArea;
Now, we need to get the coordinates and working them out.
So open savedpositions.txt you can find it in your installation folder of san andreas:
I've got the next lines:
AddPlayerClass(0,907.4069,-2069.1318,12.8326,124.6076,0,0,0,0,0,0); // find minx and miny AddPlayerClass(0,694.4529,-2249.2319,12.8326,157.1973,0,0,0,0,0,0); // finx maxx and maxy
Now get the minx and miny: 907.4069,-2069.1318
Round them: 907.4,-2069.1
Now get the maxx and minx: 694.4529,-2249.2319
Round them: 704.4,-2250.2
now we got that allready lets make the add-box:
At the top of your script:
new StuntArea, gTimer[MAX_PLAYERS]; In OnGameModeInit: <pawn> StuntArea = Area_AddBox(704.4, -2250.2, 907.4, -2069.1);
So now we get that.
we going to check if the player is in the area and is out of the area i've done it this way:
public OnPlayerEnterArea(playerid, areaid) { if(areaid == stuntArea) { SendClientMessage(playerid, 0x00FF00AA, "Welcome. Go stunting, and get money!"); gTimer[playerid] = SetTimerEx("givemon", 5000, false, "i", playerid); } return 1; } forward givemon(playerid); public givemon(playerid) { if (IsPlayerConnected(playerid)) { GivePlayerMoney(playerid, 100); } else { KillTimer(gTimer[playerid]); } return 1; } public OnPlayerLeaveArea(playerid, areaid) { if(areaid == stuntArea) { KillTimer(gTimer[playerid]); SendClientMessage(playerid, 0x00FF00AA, "You've left the stunt area"); } return 1; }
that is that we are ready now. Good luck with it!