new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;
new Vehicles[][] ={
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster",
"Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto",
"Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee",
"Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion","Rumpo",
"RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer",
"Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer",
"PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot",
"Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina","Comet","BMX",
"Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo",
"Verdewood","Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa",
"RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher","Super GT","Elegant",
"Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic",
"Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona",
"FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight",
"Streak","Vortex","Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob",
"Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
"Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
"Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
"BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
"Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)","Police Car (LVPD)","Police Ranger",
"Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
"Stair Trailer","Boxville","Farm Plow","Utility Trailer" };
public OnGameModeInit()
{
Textdraw0 = TextDrawCreate(39.000000, 285.000000, "--");//text draw do veiculo
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 3);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, 16711935);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
TextDrawTextSize(Textdraw0, 187.000000, 549.000000);
Textdraw1 = TextDrawCreate(39.000000, 300.000000, "--");//velocidade
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 3);
TextDrawLetterSize(Textdraw1, 0.500000, 1.000000);
TextDrawColor(Textdraw1, 16711935);
TextDrawSetOutline(Textdraw1, 1);
TextDrawSetProportional(Textdraw1, 1);
TextDrawTextSize(Textdraw1, 187.000000, 272.000000);
Textdraw2 = TextDrawCreate(39.000000, 315.000000, "--");//Hp (vida)
TextDrawBackgroundColor(Textdraw2, 255);
TextDrawFont(Textdraw2, 3);
TextDrawLetterSize(Textdraw2, 0.500000, 1.000000);
TextDrawColor(Textdraw2, 16711935);
TextDrawSetOutline(Textdraw2, 1);
TextDrawSetProportional(Textdraw2, 1);
TextDrawTextSize(Textdraw2, 187.000000, 272.000000);
return 1;
}
public OnGameModeExit()
{
TextDrawHideForAll(Textdraw2);
TextDrawDestroy(Textdraw2);
TextDrawHideForAll(Textdraw0);
TextDrawDestroy(Textdraw0);
TextDrawHideForAll(Textdraw1);
TextDrawDestroy(Textdraw1);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
SetTimerEx("Speed", 250, true, "i", playerid);
Speed(playerid);
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, Textdraw0);
TextDrawHideForPlayer(playerid, Textdraw1);
TextDrawHideForPlayer(playerid, Textdraw2);
}
return 1;
}
forward Speed(playerid);
public Speed(playerid)
{
new MySpeed[48];
new MyCar[48];
new MySaude[48];
new Float:Speedo_HP;
new vehicle = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicle, Speedo_HP);
format(MySpeed,sizeof(MySpeed),"~p~Speed:~y~%d Km/h",GetSpeed(playerid));
format(MyCar,sizeof(MyCar),"~r~Veiculo:~g~%s",Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
format(MySaude,sizeof(MySaude),"~p~Saude:~y~%0.0f%%",Speedo_HP/10);
TextDrawSetString(Textdraw2, MySaude);
TextDrawSetString(Textdraw1, MySpeed);
TextDrawSetString(Textdraw0, MyCar);
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2);
return 1;
}
stock GetSpeed(playerid){
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3;
return floatround(ST[3]);
}
new Text:Textdraw0[MAX_PLAYERS];
public OnGameModeInit()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
Textdraw0[i] = TextDrawCreate(39.000000, 285.000000, "--");//text draw do veiculo
TextDrawBackgroundColor(Textdraw0[i], 255);
TextDrawFont(Textdraw0[i], 3);
TextDrawLetterSize(Textdraw0[i], 0.500000, 1.000000);
TextDrawColor(Textdraw0[i], 16711935);
TextDrawSetOutline(Textdraw0[i], 1);
TextDrawSetProportional(Textdraw0[i], 1);
TextDrawTextSize(Textdraw0[i], 187.000000, 549.000000);
//continue o resto...
}
pawn Код:
|
Por que a loop no OnGameModeInit?
E por que Text:Textdraw0[MAX_PLAYERS] ? Nгo precisa de loop no OnGameModeInit para criar o TextDraw, e o TextDraw0[MAX_PlAYERS]; nгo й usado em um GameModeInit. Modo de uso do [MAX_PLAYERS] : Admin[playerid] = 0; ou if(Admin[playerid] == 1) |
bom eu uso assim no meu sistema de gps e quando nao usava dava esse mesmo bug que deu pra ele.
e o [MAX_PLAYERS] nгo й apenas para numeros por exemplo eu vou criar um carro que sera usado por varios players ao mesmo tempo e logo apos sera destruido, ae eu usaria: new Veiculo[MAX_PLAYERS]; para criar pra 1 player: Veiculo[playerid] = CreateVehicle(0, 0,0,0,0, 0, 0, 0); e para destruir: DestroyVehicle(Veiculo[playerid]); |
new Text:Textdra[3];
Mas o TextDraw no OnGameInit so vai criar o TextDraw e nгo setar o TextDraw no jogador.
E em relaзгo ao [MAX_PLAYERS], nгo precisa dele para definir o TextDraw para defenir pode ser usado: pawn Код:
No caso do TextDraw no OnGameModeInit nгo precisa de loop, porque para definir varias TextDraw nгo se usa loop. |