Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // By Seregamil
- #include <a_samp>
- #define m_a 12//arg/4=количество зон
- #define m_z 3//количество зон максимум
- #include mxINI
- new Float:pos[m_z][4];
- new areas = 0;
- new countcoords;
- new zone[m_z];
- main()
- {
- readFileZone("RDM/area.ini");
- }
- readFileZone(len[])
- {
- new str[150];
- new file = ini_openFile(len);
- ini_getString(file,"Zone",str);
- ini_closeFile(file);
- return readCoords(str);
- }
- readCoords(arg[])
- {
- new idx;
- new coord = 0;
- new area = 0;
- countcoords = 0;
- for(new x;x!=m_a;x++){
- new Float:ok = floatstr(strtok(arg, idx, ','));//read
- if(ok == 0.00000) break;//stop
- pos[area][coord] = ok;//save
- //printf("pos[%d][%d] = %f",area,coord,pos[area][coord]);//send
- coord++;//add coord
- countcoords++;
- if(coord == 4) {
- areas++;
- area++;//+1 number
- coord = 0;//0 coord
- }
- }
- if(countcoords % 4 == 0)//allcoords % 4 - yes
- {
- for(new l;l!=sizeof zone;l++) GangZoneDestroy(zone[l]);
- new zones = 0;
- for(new x;x!=areas;x++)
- {
- zone[x] = GangZoneCreate(pos[x][0],pos[x][1],pos[x][2],pos[x][3]);
- //printf("%d - created",x);
- GangZoneShowForAll(zone[x], 0x000000FF);
- zones++;
- if(zones == areas) break;
- }
- }
- printf("Количество арен:%d",areas);
- SetTimer("update",500,1);
- return 1;
- }
- forward update();
- public update()
- {
- for(new x;x!=GetMaxPlayers();x++) if(IsPlayerConnected(x) && !IsPlayerNPC(x)) search(x,areas);
- }
- new Float:xx[MAX_PLAYERS],Float:yy[MAX_PLAYERS],Float:zz[MAX_PLAYERS];
- search(playerid,&index)
- {
- new select = -1;
- for(new j;j!=index;j++)
- {
- if(InTheGangZone(playerid,pos[j][0],pos[j][1],pos[j][2],pos[j][3])) {
- save(playerid);
- select = j;
- break;
- }
- }
- if(select == -1) escape(playerid);
- }
- save(playerid)
- {
- new Float:x,Float:y,Float:z;
- if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid,x,y,z);
- else GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);
- xx[playerid] = x;
- yy[playerid] = y;
- zz[playerid] = z;
- return true;
- }
- escape(playerid)
- {
- if(!IsPlayerInAnyVehicle(playerid)) SetPlayerPos(playerid,xx[playerid],yy[playerid],zz[playerid]);
- else SetVehiclePos(playerid,xx[playerid],yy[playerid],zz[playerid]);
- return 1;
- }
- stock InTheGangZone(playerid,Float:min_x,Float:min_y,Float:max_x,Float:max_y)
- {
- new Float:xxxx,Float:yyyy,Float:zzzz;
- GetPlayerPos(playerid,xxxx,yyyy,zzzz);
- if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid),xxxx,yyyy,zzzz);
- if((xxxx <= max_x && xxxx >= min_x) && (yyyy <= max_y && yyyy >= min_y))return 1;
- return 0;
- }
- strtok(const string[], &index,seperator=' ')
- {
- new length = strlen(string);
- new offset = index;
- new result[256];
- while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- if ((index < length) && (string[index] == seperator)) index++;
- return result;
- }
- public OnPlayerSpawn(playerid)
- {
- for(new x;x!=sizeof zone;x++) GangZoneShowForPlayer(playerid,zone[x], 0x000000FF);
- return true;
- }
- // By Seregamil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement