[Ajuda] Bug estranho
#1

Bom sozinho no server funciona perfeitamente o velocimetro mais qnd por exemplo esta eu e meu amigo comeзa a bugar (qnd agente esta em um veiculo) aparece a velocidade do meu veiculo no velocimetro a minha no dele e tbm o carro se agente ta em veiculo diferente ali em Veiculo fica trocando o nome bem rapidinho pro meu e pro dele bem rapido '-'

ME AJUDEM PF =[ DO + REP sei q pra alguns significa mt ^^
pawn Код:
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]);
}
Reply
#2

pawn Код:
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...
    }
e troque todos os:
TextDrawHideForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw0);

por:
TextDrawHideForPlayer(playerid, Textdraw0[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
Reply
#3

bom amanha testarei com meu amigo... vlw ... e se alguem tiver mais uma sugestao poste ae mt obrigado... a q funfar eu deixo o rep .-.
Reply
#4

Quote:
Originally Posted by renato989920
Посмотреть сообщение
pawn Код:
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...
    }
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)
Reply
#5

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
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]);

se eu nгo usar o [MAX_PLAYERS] seria criado apenas 1 veiculo pra todos os players... e foi o que aconteceu com ele, foi criada apenas 1 textdraw para varios players
Reply
#6

Quote:
Originally Posted by renato989920
Посмотреть сообщение
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]);
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 Код:
new Text:Textdra[3];
Ai no caso do Bruno inves de Textdraw0 ficaria Textdraw[0],Textdraw[1],Textdraw[2].
No caso do TextDraw no OnGameModeInit nгo precisa de loop, porque para definir varias TextDraw nгo se usa loop.
Reply
#7

Use PlayerText.
Reply
#8

Obrigado gente pela ajuda amanha irei testar com meu amigo '-'

Meu GM qnd eu fiz tava cheio de bug e eu nem percebi '-' ja tirei uns 50 bug do BTK 2.0 o 3.0 provavelmente vai ser o ultimo :З

E acredito que vai ser um dos unicos gm's com um sistema de clгfronto '-' (em progresso ainda)


e s2 richard :3 passa skype se se lembra d mim voltando pro samp agr '-'
Reply
#9

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
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 Код:
new Text:Textdra[3];
Ai no caso do Bruno inves de Textdraw0 ficaria Textdraw[0],Textdraw[1],Textdraw[2].
No caso do TextDraw no OnGameModeInit nгo precisa de loop, porque para definir varias TextDraw nгo se usa loop.
eu nгo disse que a OnGameModeInit setaria a textdraw para o jogador e sem o loop daria o erro simbolo indefinido [i] ou [playerid], no caso nao precisaria do loop caso a callback fosse para um playerid, como a callback Speed(playerid); ai seria so colocar TextDrawShowForPlayer(playerid, textdraw[playerid]); ou TextDrawHideForPlayer(playerid, textdraw[playerid]); que serгo essas funзхes que setaram a textdraw para o jogador e nгo a callback ongamemodeinit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)