SA-MP Forums Archive
[FilterScript] Advance Double Speed-O-Meter [Version 2] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Advance Double Speed-O-Meter [Version 2] (/showthread.php?tid=656448)



Advance Double Speed-O-Meter [Version 2] - PgMNA - 16.07.2018

Hello,
This is Second version of my old speedometer, can simply change meter by /meterchange but you will need to rcon login first.

Version 1:
https://sampforum.blast.hk/showthread.php?tid=656235

Whats New?
- New 3rd Speed-O-Meter Added.
- Fixed Speed Calculations.
- Changed some Global Textdraws to PlayerTextdraws to avoid bug.


ScreenShots:
Speed-O-Meter[1]:










Speed-O-Meter[2]:







Speed-O-Meter[3]:







Downloads:
PasteBin
Mediafire

Credits:
MNA


Re: Advance Double Speed-O-Meter [Version 2] - Lokii - 16.07.2018

PHP Code:
forward CarSpawner(playerid,model);
public 
CarSpawner(playerid,model)
{
    if(
IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid0x33AA33AA"You already have a car!");
    else
    {
        new 
Float:xFloat:yFloat:zFloat:angle;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridangle);
        
//if(PlayerInfo[playerid][pCar] != -1) CarDeleter(PlayerInfo[playerid][pCar]);
        
new vehicleid=CreateVehicle(modelxyzangle, -1, -1, -1);
        
SetVehicleVirtualWorld(vehicleidGetPlayerVirtualWorld(playerid));
        
LinkVehicleToInterior(vehicleidGetPlayerInterior(playerid));
        
PutPlayerInVehicle(playeridvehicleid0);
        
ChangeVehicleColor(vehicleid,0,7);
        
//PlayerInfo[playerid][pCar] = vehicleid;
    
}
    return 
1;

why not

PHP Code:
CarSpawner(playerid,model)
{
    if(
IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid0x33AA33AA"You already have a car!");
    else
    {
        new 
Float:xFloat:yFloat:zFloat:angle;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridangle);
        
//if(PlayerInfo[playerid][pCar] != -1) CarDeleter(PlayerInfo[playerid][pCar]);
        
new vehicleid=CreateVehicle(modelxyzangle, -1, -1, -1);
        
SetVehicleVirtualWorld(vehicleidGetPlayerVirtualWorld(playerid));
        
LinkVehicleToInterior(vehicleidGetPlayerInterior(playerid));
        
PutPlayerInVehicle(playeridvehicleid0);
        
ChangeVehicleColor(vehicleid,0,7);
        
//PlayerInfo[playerid][pCar] = vehicleid;
    
}
    return 
1;

AND

why use 3 callbacks 1 to get health 2 to set speedtextdraw and 3 get speed while this could be done in 1 callback

You could use 1 timer

Why include foreach and not use it?

Why dont you destroy player text draw when player leaves


Re: Advance Double Speed-O-Meter [Version 2] - Freaksken - 16.07.2018

Quote:
Originally Posted by Lokii
View Post
Why dont you destroy player text draw when player leaves
SA-MP does that automatically.


Re: Advance Double Speed-O-Meter [Version 2] - Usmanmemon - 16.07.2018

Nice Work Bro, i Know you.


Re: Advance Double Speed-O-Meter [Version 2] - PgMNA - 16.07.2018

Quote:
Originally Posted by Lokii
View Post
PHP Code:
forward CarSpawner(playerid,model);
public 
CarSpawner(playerid,model)
{
    if(
IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid0x33AA33AA"You already have a car!");
    else
    {
        new 
Float:xFloat:yFloat:zFloat:angle;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridangle);
        
//if(PlayerInfo[playerid][pCar] != -1) CarDeleter(PlayerInfo[playerid][pCar]);
        
new vehicleid=CreateVehicle(modelxyzangle, -1, -1, -1);
        
SetVehicleVirtualWorld(vehicleidGetPlayerVirtualWorld(playerid));
        
LinkVehicleToInterior(vehicleidGetPlayerInterior(playerid));
        
PutPlayerInVehicle(playeridvehicleid0);
        
ChangeVehicleColor(vehicleid,0,7);
        
//PlayerInfo[playerid][pCar] = vehicleid;
    
}
    return 
1;

why not

PHP Code:
CarSpawner(playerid,model)
{
    if(
IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid0x33AA33AA"You already have a car!");
    else
    {
        new 
Float:xFloat:yFloat:zFloat:angle;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridangle);
        
//if(PlayerInfo[playerid][pCar] != -1) CarDeleter(PlayerInfo[playerid][pCar]);
        
new vehicleid=CreateVehicle(modelxyzangle, -1, -1, -1);
        
SetVehicleVirtualWorld(vehicleidGetPlayerVirtualWorld(playerid));
        
LinkVehicleToInterior(vehicleidGetPlayerInterior(playerid));
        
PutPlayerInVehicle(playeridvehicleid0);
        
ChangeVehicleColor(vehicleid,0,7);
        
//PlayerInfo[playerid][pCar] = vehicleid;
    
}
    return 
1;

AND

why use 3 callbacks 1 to get health 2 to set speedtextdraw and 3 get speed while this could be done in 1 callback

You could use 1 timer

Why include foreach and not use it?

Why dont you destroy player text draw when player leaves
that code i used to spawn car in server forgot to remove and all other things are perfectly fine!


Re: Advance Double Speed-O-Meter [Version 2] - xMoBi - 17.07.2018

Code:
//speedo1
new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;
new PlayerText:Textdraw3[MAX_PLAYERS];
new Text:Textdraw4;
new Text:Textdraw5;
new PlayerText:Textdraw6[MAX_PLAYERS];
new PlayerText:Textdraw7[MAX_PLAYERS];
new PlayerText:Textdraw8[MAX_PLAYERS];
new PlayerText:Textdraw9[MAX_PLAYERS];
new PlayerText:Textdraw10[MAX_PLAYERS];
new PlayerText:Textdraw11[MAX_PLAYERS];
new PlayerText:Textdraw12[MAX_PLAYERS];
 
//speedo2
 
new Text:speedom0;
new Text:speedom1;
new Text:speedom2;
new PlayerText:speedom3[MAX_PLAYERS];
new PlayerText:speedom4[MAX_PLAYERS];
new PlayerText:speedom5[MAX_PLAYERS];
new PlayerText:speedom6[MAX_PLAYERS];
new PlayerText:speedom7[MAX_PLAYERS];
new PlayerText:speedom8[MAX_PLAYERS];
new PlayerText:speedom9[MAX_PLAYERS];
new PlayerText:speedom10[MAX_PLAYERS];
new PlayerText:speedom11[MAX_PLAYERS];
new PlayerText:speedom12[MAX_PLAYERS];
new PlayerText:speedom13[MAX_PLAYERS];
new PlayerText:speedom14[MAX_PLAYERS];
new PlayerText:speedom15[MAX_PLAYERS];
new PlayerText:speedom16[MAX_PLAYERS];
new Text:speedom17;
new Text:speedom18;
new Text:speedom19;
new PlayerText:speedom20[MAX_PLAYERS];
new PlayerText:speedom21[MAX_PLAYERS];
new PlayerText:speedom22[MAX_PLAYERS];
new Text:speedom23;
 
//speed02
new Text:speedm0;
new Text:speedm1;
new PlayerText:speedm2[MAX_PLAYERS];
new Text:speedm3;
new PlayerText:speedm4[MAX_PLAYERS];
new PlayerText:speedm5[MAX_PLAYERS];
new Text:speedm6;
new PlayerText:speedm7[MAX_PLAYERS];
new PlayerText:speedm8[MAX_PLAYERS];
new PlayerText:speedm9[MAX_PLAYERS];
new PlayerText:speedm10[MAX_PLAYERS];
nice naming of variables.

all textdraws are global.

worst indentation.

lots of public functions - useless.

repeated code at lots of places.

untidy code and bad looking textdraws.

fix them all.


Re: Advance Double Speed-O-Meter [Version 2] - PgMNA - 17.07.2018

Quote:
Originally Posted by xMoBi
View Post
Code:
//speedo1
new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;
new PlayerText:Textdraw3[MAX_PLAYERS];
new Text:Textdraw4;
new Text:Textdraw5;
new PlayerText:Textdraw6[MAX_PLAYERS];
new PlayerText:Textdraw7[MAX_PLAYERS];
new PlayerText:Textdraw8[MAX_PLAYERS];
new PlayerText:Textdraw9[MAX_PLAYERS];
new PlayerText:Textdraw10[MAX_PLAYERS];
new PlayerText:Textdraw11[MAX_PLAYERS];
new PlayerText:Textdraw12[MAX_PLAYERS];
 
//speedo2
 
new Text:speedom0;
new Text:speedom1;
new Text:speedom2;
new PlayerText:speedom3[MAX_PLAYERS];
new PlayerText:speedom4[MAX_PLAYERS];
new PlayerText:speedom5[MAX_PLAYERS];
new PlayerText:speedom6[MAX_PLAYERS];
new PlayerText:speedom7[MAX_PLAYERS];
new PlayerText:speedom8[MAX_PLAYERS];
new PlayerText:speedom9[MAX_PLAYERS];
new PlayerText:speedom10[MAX_PLAYERS];
new PlayerText:speedom11[MAX_PLAYERS];
new PlayerText:speedom12[MAX_PLAYERS];
new PlayerText:speedom13[MAX_PLAYERS];
new PlayerText:speedom14[MAX_PLAYERS];
new PlayerText:speedom15[MAX_PLAYERS];
new PlayerText:speedom16[MAX_PLAYERS];
new Text:speedom17;
new Text:speedom18;
new Text:speedom19;
new PlayerText:speedom20[MAX_PLAYERS];
new PlayerText:speedom21[MAX_PLAYERS];
new PlayerText:speedom22[MAX_PLAYERS];
new Text:speedom23;
 
//speed02
new Text:speedm0;
new Text:speedm1;
new PlayerText:speedm2[MAX_PLAYERS];
new Text:speedm3;
new PlayerText:speedm4[MAX_PLAYERS];
new PlayerText:speedm5[MAX_PLAYERS];
new Text:speedm6;
new PlayerText:speedm7[MAX_PLAYERS];
new PlayerText:speedm8[MAX_PLAYERS];
new PlayerText:speedm9[MAX_PLAYERS];
new PlayerText:speedm10[MAX_PLAYERS];
nice naming of variables.

all textdraws are global.

worst indentation.

lots of public functions - useless.

repeated code at lots of places.

untidy code and bad looking textdraws.

fix them all.
- see from open eyes not all textdraws are global.
- i have tested it and it doesnot drop fps.
- no repeated codes
- no untidy codes found you are the one who is a jelous peep nigga.


Re: Advance Double Speed-O-Meter [Version 2] - Lokii - 17.07.2018

Quote:
Originally Posted by PgMNA
View Post
- see from open eyes not all textdraws are global.
- i have tested it and it doesnot drop fps.
- no repeated codes
- no untidy codes found you are the one who is a jelous peep nigga.
People try to help you optimize you'r code and you'r being rude to them.

also you should calculate the vehicle health

when the vehicle will be on fire the health will show between 0-250 and i usually prefer when the max health is 100 not 1000.

PHP Code:
GetVehicleHP(vehicleid)
{
    new 
veh_hp_resultFloat:veh_hp;
    
GetVehicleHealth(vehicleidveh_hp);
    
veh_hp_result floatround((floatsub(veh_hp250))/7.5);
    if(
veh_hp_result 0) return veh_hp_result;
    return 
0;




Re: Advance Double Speed-O-Meter [Version 2] - CodeStyle175 - 17.07.2018

what are you even talking about?


Re: Advance Double Speed-O-Meter [Version 2] - xMoBi - 17.07.2018

Quote:
Originally Posted by PgMNA
View Post
- see from open eyes not all textdraws are global.
- i have tested it and it doesnot drop fps.
- no repeated codes
- no untidy codes found you are the one who is a jelous peep nigga.
Do you know what is arrays?
The textdraws look horrible.
You repeat the code where you kill timers and the textdraws.
you've bunch of un-used callbacks there.

You're the one who is blind.