Problem with Speedometer
#1

Hey Guys!

I need a help from you, because i don't get it, what's wrong with this command?
Sorry for my bad English...

Here iz the code:

#include <a_samp>

new SpeedUse[MAX_PLAYERS];
new SpeedTimer[MAX_PLAYERS] = -1;
forward ShowCarSpeed(const playerid);

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif

public OnPlayerConnect(playerid)
{
SpeedTimer[playerid] = SetTimerEx("ShowCarSpeed", 500, true, "d", playerid);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
if(SpeedUse[playerid] == 1)
{
TextDrawShowForPlayer(playerid, Text:Speed[playerid]);
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/speedometer", cmdtext, true, 10) == 0)
{
if(SpeedUse[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "*Speedometer is disabled!");
SpeedUse[playerid] == 0;
return 1;
}
if(SpeedUse[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "*Speedometer is enabled!");
SpeedUse[playerid] == 1;
return 1;
}
}
return 0;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_ONFOOT)
{
if(SpeedUse[playerid] == 1)
{
TextDrawHideForPlayer(playerid, Text:Speed[playerid]);
}
}
return 1;
}

public ShowCarSpeed(const playerid)
{
new Float:fPos[3], Float:fSpeed;
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleVelocity(vehicleid, fPos[0], fPos[1], fPos[2]);
fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) + floatpower(fPos[2], 2)) * 200;

if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(SpeedUse[playerid] == 1)
{
format(stringe, MAX_STRING,"~r~%d ~g~km/h", floatround(fSpeed));
TextDrawSetString(Speed[playerid], stringe);
}
}
else
{
TextDrawHideForPlayer(playerid, Text:Speed[playerid]);
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
if(GetPlayerWeapon(playerid) != 0)
{
if(VehicleDriver(GetPlayerVehicleID(playerid)) == INVALID_PLAYER_ID)
{
SetPlayerArmedWeapon(playerid, 0);
}
}
}
}
}
else
{
TextDrawHideForPlayer(playerid, Text:Speed[playerid]);
GetPlayerVelocity(playerid, fPos[0], fPos[1], fPos[2]);
fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) + floatpower(fPos[2], 2)) * 200;
}
return 1;
}



And the errors is:


C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : error 017: undefined symbol "Speed"
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : warning 215: expression has no effect
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : fatal error 107: too many error messages on one line



Can someone help me? Please.
Reply
#2

would you mind putting all your code into [pawn ] [/ pawn] tags to make it readable.
Reply
#3

pawn Code:
#include <a_samp>

new SpeedUse[MAX_PLAYERS];
new SpeedTimer[MAX_PLAYERS] = -1;
forward ShowCarSpeed(const playerid);

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif

public OnPlayerConnect(playerid)
{
SpeedTimer[playerid] = SetTimerEx("ShowCarSpeed", 500, true, "d", playerid);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
if(SpeedUse[playerid] == 1)
{
TextDrawShowForPlayer(playerid, Text:Speed[playerid]);
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/speedometer", cmdtext, true, 10) == 0)
{
if(SpeedUse[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "*Speedometer is disabled!");
SpeedUse[playerid] == 0;
return 1;
}
if(SpeedUse[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "*Speedometer is enabled!");
SpeedUse[playerid] == 1;
return 1;
}
}
return 0;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_ONFOOT)
{
if(SpeedUse[playerid] == 1)
{
TextDrawHideForPlayer(playerid, Text:Speed[playerid]);
}
}
return 1;
}

public ShowCarSpeed(const playerid)
{
new Float:fPos[3], Float:fSpeed;
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleVelocity(vehicleid, fPos[0], fPos[1], fPos[2]);
fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) + floatpower(fPos[2], 2)) * 200;

if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(SpeedUse[playerid] == 1)
{
format(stringe, MAX_STRING,"~r~%d ~g~km/h", floatround(fSpeed));
TextDrawSetString(Speed[playerid], stringe);
}
}
else
{
TextDrawHideForPlayer(playerid, Text:Speed[playerid]);
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
if(GetPlayerWeapon(playerid) != 0)
{
if(VehicleDriver(GetPlayerVehicleID(playerid)) == INVALID_PLAYER_ID)
{
SetPlayerArmedWeapon(playerid, 0);
}
}
}
}
}
else
{
TextDrawHideForPlayer(playerid, Text:Speed[playerid]);
GetPlayerVelocity(playerid, fPos[0], fPos[1], fPos[2]);
fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) + floatpower(fPos[2], 2)) * 200;
}
return 1;
}

And errors are:

pawn Code:
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : error 017: undefined symbol "Speed"
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : warning 215: expression has no effect
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\SAMP03~1\ pawno\FORSCR~1\Speedo\speedo.pwn(43) : fatal error 107: too many error messages on one line
Reply
#4

Can someone help me, please?
Reply
#5

have you defined "Speed"?
Reply
#6

Under "#include <a_samp> i have 3 things:

pawn Code:
new SpeedUse[MAX_PLAYERS];
new SpeedTimer[MAX_PLAYERS] = -1;
forward ShowCarSpeed(const playerid);
Reply
#7

pawn Code:
//At top.
new Text:Speed[MAX_PLAYERS];
Reply
#8

When i add this code:

pawn Code:
new Text:Speed[MAX_PLAYERS];
It's show me a new errors:

pawn Code:
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\pawno\Speedo.pwn(128) : warning 217: loose indentation
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\pawno\Speedo.pwn(128) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\pawno\Speedo.pwn(128) : error 004: function "ShowCarSpeed" is not implemented
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\pawno\Speedo.pwn(128) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Home\Desktop\Guntis\JAUNAI~2\pawno\Speedo.pwn(128) : fatal error 107: too many error messages on one line
<---------------------------------------->

pawn Code:
public ShowCarSpeed(const playerid) //This is the 128 line
Reply
#9

playerid is not a constant value.
And forward the function.
pawn Code:
public ShowCarSpeed(playerid)
Reply
#10

Still, doesn't work.
Reply
#11

Can some one help me, please?
Reply
#12

Alright. Just a sec, I will show you my code.

On top of the GM/FS

PHP Code:
new Text:SPEEDOS[MAX_PLAYERS];  //speedometer 
OnPlayerConnect put this
PHP Code:
SPEEDOS[playerid] = TextDrawCreate(10.0,200.0," ");
TextDrawShowForPlayer(playerid,SPEEDOS[playerid]); 
OnPlayerUpdate add this
PHP Code:
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
    
vehicleid GetPlayerVehicleID(playerid);
    if(
vehicleid != 0)
    {
        
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
        
final_speed floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
        
final_speed_int floatround(final_speed,floatround_round);
        
format(speed_string,256,"Speed: %i",final_speed_int);
        
TextDrawSetString(SPEEDOS[playerid], speed_string);
    }
    else
    {
        
TextDrawSetString(SPEEDOS[playerid], " ");
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)