10.01.2012, 16:15
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