Filterscript only working for ID 0 (speedometer)
#1

I downloaded this speedometer, but it does only work for the player with the id 0
pawn Код:
#define FILTERSCRIPT
//-------------------------------------------------------
#include <a_samp>
//-------------------------------------------------------
new Text:SPEEDOS[MAX_PLAYERS];
//-------------------------------------------------------
forward Speedometer(playerid);
//-------------------------------------------------------
public OnFilterScriptInit()
{
    SetTimer("Speedometer", 100, true);
    return 1;
}
//-------------------------------------------------------
public OnPlayerConnect(playerid)
{
    SPEEDOS[playerid] = TextDrawCreate(500.0,400.0," ");
    TextDrawShowForPlayer(playerid,SPEEDOS[playerid]);
    return 1;
}
//-------------------------------------------------------
public Speedometer(playerid)
{
    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))*250.666667; // 250.666667 = kmph  // 199,4166672= mph
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"%i km/h",final_speed_int);
        TextDrawSetString(SPEEDOS[playerid], speed_string);
    }
    else
    {
        TextDrawSetString(SPEEDOS[playerid], " ");
    }
    return 1;
}
//-------------------------------------------------------
Reply
#2

You need to use Player Textdraws, not default global textdraws
Reply
#3

PHP код:
SetTimerEx("Speedometer"100true,"i",playerid); 
Reply
#4

You need to be using player textdraws for this kind of stuff, not general server textdraws. Whoever made that script either made it for only the first player, or just did it wrong to begin with.
Reply
#5

and https://sampwiki.blast.hk/wiki/VectorSize instead of floatsqroot
Reply
#6

Ok, I tried doing the player textdraws.
I got these errors now:
Код:
C:\Users\Ruud\Documents\Samp\RP alles in 1\filterscripts\speedometer.pwn(17) : warning 213: tag mismatch
C:\Users\Ruud\Documents\Samp\RP alles in 1\filterscripts\speedometer.pwn(18) : warning 213: tag mismatch
This is my code:
Код:
#define FILTERSCRIPT
//-------------------------------------------------------
#include <a_samp>
//-------------------------------------------------------
new Text:SPEEDOS[MAX_PLAYERS];
//-------------------------------------------------------
forward Speedometer(playerid);
//-------------------------------------------------------
public OnFilterScriptInit()
{
	SetTimer("Speedometer", 100, true);
	return 1;
}
//-------------------------------------------------------
public OnPlayerConnect(playerid)
{
	SPEEDOS[playerid] = CreatePlayerTextDraw(playerid, 500.0, 400.0, " ");
	PlayerTextDrawShow(playerid, SPEEDOS[playerid]);
	return 1;
}
//-------------------------------------------------------
public Speedometer(playerid)
{
	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))*250.666667; // 250.666667 = kmph  // 199,4166672= mph
		final_speed_int = floatround(final_speed,floatround_round);
		format(speed_string,256,"%i km/h",final_speed_int);
		TextDrawSetString(SPEEDOS[playerid], speed_string);
	}
	else
	{
		TextDrawSetString(SPEEDOS[playerid], " ");
	}
    return 1;
}
//-------------------------------------------------------
Reply
#7

You still have things like "TextDrawSetString" in your script. Pretty much all textdraw functions such start with the prefix "Player", along with playerid being the first parameter.
Reply
#8

Like this then?
Код:
#define FILTERSCRIPT
//-------------------------------------------------------
#include <a_samp>
//-------------------------------------------------------
new Text:SPEEDOS[MAX_PLAYERS];
//-------------------------------------------------------
forward Speedometer(playerid);
//-------------------------------------------------------
public OnFilterScriptInit()
{
	SetTimer("Speedometer", 100, true);
	return 1;
}
//-------------------------------------------------------
public OnPlayerConnect(playerid)
{
	SPEEDOS[playerid] = CreatePlayerTextDraw(playerid, 500.0, 400.0, " ");
	PlayerTextDrawShow(playerid, SPEEDOS[playerid]);
	return 1;
}
//-------------------------------------------------------
public Speedometer(playerid)
{
	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))*250.666667; // 250.666667 = kmph  // 199,4166672= mph
		final_speed_int = floatround(final_speed,floatround_round);
		format(speed_string,256,"%i km/h",final_speed_int);
		PlayerTextDrawSetString(playerid, SPEEDOS[playerid], speed_string);
	}
	else
	{
		PlayerTextDrawSetString(playerid, SPEEDOS[playerid], " ");
	}
    return 1;
}
//-------------------------------------------------------
Got these errors on those lines:
Код:
C:\Users\Ruud\Documents\Samp\RP alles in 1\filterscripts\speedometer.pwn(17) : warning 213: tag mismatch
C:\Users\Ruud\Documents\Samp\RP alles in 1\filterscripts\speedometer.pwn(18) : warning 213: tag mismatch
C:\Users\Ruud\Documents\Samp\RP alles in 1\filterscripts\speedometer.pwn(32) : warning 213: tag mismatch
C:\Users\Ruud\Documents\Samp\RP alles in 1\filterscripts\speedometer.pwn(36) : warning 213: tag mismatch
Reply
#9

NVM, I fixed the error.
new PlayerText:SPEEDOS[MAX_PLAYERS];
Reply
#10

Quote:
Originally Posted by Matess
Посмотреть сообщение
PHP код:
SetTimerEx("Speedometer"100true,"i",playerid); 
Quote:
Originally Posted by Jefff
Посмотреть сообщение
And what's the difference if I don't use this?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)