Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_MOBILE (50)
- enum MobileStationEx
- {
- aID,
- Float:aX,
- Float:aY,
- Float:aZ,
- aRadius,
- };
- new MobileInfo[MAX_MOBILE][MobileStationEx], TOTALSTATION;
- new SignalStation[MAX_PLAYERS];
- mysql_tquery(dbHandle, "SELECT * FROM "T_MOBILE"", "@LoadMobileStation", "");
- @LoadMobileStation();
- @LoadMobileStation()
- {
- new time = GetTickCount();
- #if MYSQL_R41_2 == true
- new rows;
- cache_get_row_count(rows);
- if(rows)
- {
- for(new idx = 1; idx <= rows; idx++)
- {
- cache_get_value_index_int(idx-1, 0, MobileInfo[idx][aID]); // ID
- cache_get_value_index_float(idx-1, 1, MobileInfo[idx][aX]); // aX
- cache_get_value_index_float(idx-1, 2, MobileInfo[idx][aY]); // aY
- cache_get_value_index_float(idx-1, 3, MobileInfo[idx][aZ]); // aZ
- cache_get_value_index_float(idx-1, 4, MobileInfo[idx][aRadius]); // aRadius
- TOTALSTATION++;
- MobileStation[idx] = CreateObject(3763, MobileInfo[idx][aX], MobileInfo[idx][aY], MobileInfo[idx][aZ], 0.0,0.0,0.0);
- }
- }
- #else
- new rows, fields;
- cache_get_data(rows, fields);
- if(rows)
- {
- for(new idx = 1; idx <= rows; idx++)
- {
- MobileInfo[idx][aID] = cache_get_row_int(idx-1, 0, dbHandle); // ID
- MobileInfo[idx][aX] = cache_get_row_float(idx-1, 1, dbHandle); // aX
- MobileInfo[idx][aY] = cache_get_row_float(idx-1, 2, dbHandle); // aY
- MobileInfo[idx][aZ] = cache_get_row_float(idx-1, 3, dbHandle); // aZ
- TOTALSTATION++;
- MobileStation[idx] = CreateObject(3763, MobileInfo[idx][aX], MobileInfo[idx][aY], MobileInfo[idx][aZ], 0.0,0.0,0.0);
- }
- }
- #endif
- printf("[Çàãðóæåíî ñòàíöèé]: <%i>. Ïîòðà÷åíî: <%i ms>.", TOTALSTATION, GetTickCount() - time);
- return 1;
- }
- stock GetPlayerClosestMobileStation(playerid)
- {
- new id=-1, Float:dist=0.0, Float:mindist=9999.0;
- for(new i=0; i<MAX_MOBILE; i++)
- {
- if(MobileInfo[i][aID])
- {
- dist=GetPlayerDistanceFromPoint(playerid,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]);
- if(dist < MobileInfo[i][aRadius])
- {
- if(dist < mindist)
- {
- mindist=dist;
- id=i;
- }
- }
- }
- }
- return id;
- }
- stock SignalSetString(playerid)
- {
- new str[255];
- switch(SignalStation[playerid])
- {
- case -1:
- str = "~g~Phone Signal: ~y~!~b~offline";
- case 0:
- str = "~g~Phone Signal: ~y~!~b~lost";
- case 1:
- str = "~g~Phone Signal: ~y~!~b~-";
- case 2:
- str = "~g~Phone Signal: ~y~!~b~--";
- case 3:
- str = "~g~Phone Signal: ~y~!~b~---";
- case 4:
- str = "~g~Phone Signal: ~y~!~b~----";
- case 5:
- str = "~g~Phone Signal: ~y~!~b~-----";
- }
- return str;
- }
- stock GetSignal(playerid)
- {
- new i=GetPlayerClosestMobileStation(playerid);
- if(i!=-1)
- {
- if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*1,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
- return 5;
- else if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*2,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
- return 4;
- else if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*3,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
- return 3;
- else if(IsPlayerInRangeOfPoint(playerid,MobileInfo[i][aRadius]/5*4,MobileInfo[i][aX],MobileInfo[i][aY],MobileInfo[i][aZ]))
- return 2;
- else
- return 1;
- }
- else
- return 0;
- }
- Обновление в 1 секунду таймер
- if(GetPlayerInterior(i)==0)
- Signal[i]=GetSignal(i);
- new sdstring[128];
- format(sdstring,128,"%s",SignalSetString(i));
- TextDrawSetString(mobile_text_TD[i],sdstring);
- проверки
- else if(!Signal[plidx]) return SendClientMessage(playerid,COLOR_WHITE,"[Îøèáêà] Ó àáîíåíòà âðåìåííî íåò çîíû");
- else if(!Signal[playerid]) return SendClientMessage(playerid,COLOR_WHITE,"[Îøèáêà] Ó àáîíåíòà âðåìåííî íåò çîíû");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement