17.04.2017, 14:25
I've made a /gps command and when i select a location it show a message but the textdraw is not showing
This is the textdraw:
I put it at OnPlayerConnect
The rest of the gps system:
This is the textdraw:
Код:
Textdraw53[playerid] = TextDrawCreate(320.000000, 341.000000, " "); // GPS TextDrawAlignment(Textdraw53[playerid], 2); TextDrawBackgroundColor(Textdraw53[playerid], 255); TextDrawFont(Textdraw53[playerid], 2); TextDrawLetterSize(Textdraw53[playerid], 0.400000, 1.500000); TextDrawColor(Textdraw53[playerid], -1); TextDrawSetOutline(Textdraw53[playerid], 1); TextDrawSetProportional(Textdraw53[playerid], 1);
The rest of the gps system:
Код:
CMD:gps(playerid,params[]) { if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te loghezi mai intai."); if(IsPlayerConnected(playerid)) { if(IsPlayerInAnyVehicle(playerid)) { new list[] = "1\tArmy HQ\n2\tLicenses Center\n3\tOff Road Dealership\n4\tCar Graveyard\n5\tCoutz And Shoutz\n6\tABC Studio\n7\tFBI HQ\n8\tAmmunation\n9\tHosptial\n10\tGROTTI\n11\tRPL\n12\tLSFD\n13\tLowriderz Dealership\n14\tCity Hall\n15\tLSPD\n16\tTaxi Co. HQ\n17\tBoats Dealership\n18\tTrucks Dealership\n19\tSF Docks\n20\tLVAP Deliver"; ShowPlayerDialog(playerid, 1240,DIALOG_STYLE_LIST,"G.P.S Positions",list,"Track","Off"); SendClientMessage(playerid, COLOR_GREY,"* You do not have a GPS, displaying only basic positions, buy a Full GPS at any 24/7"); SendClientMessage(playerid, COLOR_GREY,"* To turn the GPS Off, Type /gps again and select OFF"); } else { SendClientMessage(playerid, COLOR_GREY, "* GPS can be only used while in a Vehicle"); return 1; } } return 1; } CMD:gpsfind(playerid,params[]) { new Float:x, Float:y; new string[100]; if (sscanf(params, "ff", x, y)) { SendClientMessage(playerid, 0xBBBBBBAA, "TIP: /gpsfind <X> <Y>"); SendClientMessage(playerid, 0xBBBBBBAA, "TIP: /gpsfind 0 0 To turn it off."); return 1; } else { if((x == 0 && y == 0)) { SendClientMessage(playerid, 0xFFFFFFFF, "You have Turned off your GPS"); TextDrawHideForPlayer(playerid, Textdraw53[playerid]); } else { if(IsPlayerInAnyVehicle(playerid)) { SetPlayerRouting(playerid, x,y); format(string, sizeof(string), "You've set your coord to %f, %f", x, y); SendClientMessage(playerid, 0xFFFFFFFF, string); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); } else { SendClientMessage(playerid, COLOR_GREY, "* You are not in a vehicle"); return 1; } } } return 1; }
Код:
if(dialogid == 1240) { if(response) { if(listitem == 0) { TelePosGps[playerid][tX] = 2717.9792; TelePosGps[playerid][tY] = -2405.2048; SetPlayerRouting(playerid, 2717.9792,-2405.2048); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Army Base"); } else if(listitem == 1) { TelePosGps[playerid][tX] = 2047.0006; TelePosGps[playerid][tY] = -1905.5575; SetPlayerRouting(playerid, 2047.0006,-1905.5575); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Licenses Center"); } else if(listitem == 2) { TelePosGps[playerid][tX] = 2514.7600; TelePosGps[playerid][tY] = -1519.4685; SetPlayerRouting(playerid, 2514.7600,-1519.4685); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Off Roads Dealership"); } else if(listitem == 3) { TelePosGps[playerid][tX] = 2596.6575; TelePosGps[playerid][tY] = -1632.2941; SetPlayerRouting(playerid, 2596.6575,-1632.2941); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Car Graveyard"); } else if(listitem == 4) { TelePosGps[playerid][tX] = 2127.0134; TelePosGps[playerid][tY] = -1137.1017; SetPlayerRouting(playerid, 2127.0134,-1137.1017); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Coutz And Shoutz Dealership"); } else if(listitem == 5) { TelePosGps[playerid][tX] = 1789.3593; TelePosGps[playerid][tY] = -1294.4882; SetPlayerRouting(playerid, 1789.3593,-1294.4882); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking ABC Studio"); } else if(listitem == 6) { TelePosGps[playerid][tX] = 1520.9916; TelePosGps[playerid][tY] = -1450.6512; SetPlayerRouting(playerid, 1520.9916,-1450.6512); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking FBI HQ"); } else if(listitem == 7) { TelePosGps[playerid][tX] = 1367.3927; TelePosGps[playerid][tY] = -1278.2708; SetPlayerRouting(playerid, 1367.3927,-1278.2708); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Ammunation"); } else if(listitem == 8) { TelePosGps[playerid][tX] = 1175.9061; TelePosGps[playerid][tY] = -1323.3114; SetPlayerRouting(playerid, 1175.9061,-1323.3114); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Hospital"); } else if(listitem == 9) { TelePosGps[playerid][tX] = 551.9272; TelePosGps[playerid][tY] = -1274.9121; SetPlayerRouting(playerid, 551.9272,-1274.9121); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking GROTTI"); } else if(listitem == 10) { TelePosGps[playerid][tX] = 478.5240; TelePosGps[playerid][tY] = -1495.4603; SetPlayerRouting(playerid, 478.5240,-1495.4603); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Regulars Lounge"); } else if(listitem == 11) { TelePosGps[playerid][tX] = 617.9719; TelePosGps[playerid][tY] = -1530.0857; SetPlayerRouting(playerid, 617.9719,-1530.0857); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking LS Fire Department"); } else if(listitem == 12) { TelePosGps[playerid][tX] = 298.1871; TelePosGps[playerid][tY] = -1517.8085; SetPlayerRouting(playerid, 298.1871,-1517.8085); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Low Riders Dealership"); } else if(listitem == 13) { TelePosGps[playerid][tX] = 1484.6884; TelePosGps[playerid][tY] = -1771.7438; SetPlayerRouting(playerid, 1484.6884,-1771.7438); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking City Hall"); } else if(listitem == 14) { TelePosGps[playerid][tX] = 1550.1317; TelePosGps[playerid][tY] = -1376.0255; SetPlayerRouting(playerid, 1550.1317,-1676.0225); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking LS Police Department"); } else if(listitem == 15) { TelePosGps[playerid][tX] = 1755.1904; TelePosGps[playerid][tY] = -1839.9189; SetPlayerRouting(playerid, 1755.1904,-1893.9189); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Taxi Co. HQ"); } else if(listitem == 16) { TelePosGps[playerid][tX] = 2518.1897; TelePosGps[playerid][tY] = -2233.4109; SetPlayerRouting(playerid, 2518.1897,-2233.4109); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Boats Dealership"); } else if(listitem == 17) { TelePosGps[playerid][tX] = 1099.9955; TelePosGps[playerid][tY] = -1202.0293; SetPlayerRouting(playerid, 1099.9951,-1202.0293); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Trucks Dealership");//asdda } else if(listitem == 18) { TelePosGps[playerid][tX] = -1596.1532; TelePosGps[playerid][tY] = 115.1059; SetPlayerRouting(playerid, -1596.1532,115.1059); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking San Fierro Exportations Docks"); } else if(listitem == 19) { TelePosGps[playerid][tX] = 1432.1233; TelePosGps[playerid][tY] = 1396.5969; SetPlayerRouting(playerid, 1432.1233,1396.5969); TextDrawShowForPlayer(playerid, Textdraw53[playerid]); SendClientMessage(playerid, COLOR_GREY,"* Now Tracking Las Venturas Airport Exportation Point"); } } }
Код:
stock SetPlayerRouting(playerid, Float:x1, Float:y1) { if(IsPlayerInAnyVehicle(playerid)) { new string[128]; new textstring[200]; new Float:x2, Float:y2, Float:z2; new Float:angle2; GetVehiclePos(GetPlayerVehicleID(playerid), x2, y2, z2); GetVehicleZAngle(GetPlayerVehicleID(playerid), angle2); new Float:dist; dist = floatsqroot(floatpower(floatabs(floatsub(x1,x2)),2)+floatpower(floatabs(floatsub(y1,y2)),2)); new Float:angle1; if( (y1-y2) >= 0.0) angle1 = acos((x1-x2)/dist) - 90; else angle1 = 270 - acos((x1-x2)/dist); new Float:offset; offset = 360.0 - angle2 + angle1; if(offset >= 360.0) offset = offset - 360.0; else if(offset < 0.0) offset = offset + 360.0; if(offset >= 330.0 || offset < 30.0) format(string, sizeof(string), "~u~ ~w~%d ~u~", floatround(dist)); else if(offset >= 30.0 && offset < 60.0) format(string, sizeof(string), "~<~ ~w~%d", floatround(dist)); else if(offset >= 60.0 && offset < 100.0) format(string, sizeof(string), "~<~~<~ ~w~%d", floatround(dist)); else if(offset >= 100.0 && offset < 150.0) format(string, sizeof(string), "~d~~<~ ~w~%d", floatround(dist)); else if(offset >= 150.0 && offset < 210.0) format(string, sizeof(string), "~d~ ~w~%d ~d~", floatround(dist)); else if(offset >= 210.0 && offset < 260.0) format(string, sizeof(string), "~w~%d ~>~~d~", floatround(dist)); else if(offset >= 260.0 && offset < 300.0) format(string, sizeof(string), "~w~%d ~>~~>~", floatround(dist)); else if(offset >= 300.0 && offset < 330.0) format(string, sizeof(string), "~w~%d ~>~", floatround(dist)); format(textstring,sizeof(textstring),"~r~Global Positionating System ~n~~n~~y~Tracking Coordinates: ~w~~n~X %.01f - Y %.01f ~n~~n~ ~y~Distance & Direction: ~n~%s", x1, y1, string); TextDrawSetString(Textdraw53[playerid],textstring); if(floatround(dist) <= 25) { format(textstring,sizeof(textstring),"~r~Global Positionating System ~n~~n~~y~Tracking Coordinates: ~w~~n~X %.01f - Y %.01f ~n~~n~ ~p~Arrived at Position!", x1, y1); TextDrawSetString(Textdraw53[playerid],textstring); } TelePosGps[playerid][tX] = x1; TelePosGps[playerid][tY] = y1; } return 1; }
Код:
enum TelePosEnum { Float:tX, Float:tY }; new Float:TelePosGps[MAX_PLAYERS][TelePosEnum];
Код:
forward GpsCheck(); public GpsCheck() { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(IsPlayerInAnyVehicle(i)) { SetPlayerRouting(i,TelePosGps[i][tX],TelePosGps[i][tY]); } } } return 1; }
Код:
SetTimer("GpsCheck",1250,true);