Рекомендованные сообщения



Не найдено.

2 posts in this topic

Приветствую всех пользователей, и скриптеров портала PAWNO-RUS.RU

Уважаемые скриптеры. Объясните пожалуйста как правильно связать спидометр с TextDraw? Что бы показывалась Speed, Fuel и т.п

Буду очень благодарен, так же не забуду поставить "+сик)"

Share this post


Link to post
Share on other sites

Используй PlayerTextDraw(Тд для определенного игрока), после же используй уже PlayerTextDrawSetString. Можно погуглить узнать в вики что это за функции. Через эти функции делаются спидометры. Вот тебе пример:

new PlayerText:CarSpeed[MAX_PLAYERS];
new SpeedTimer[MAX_PLAYERS];


stock CreatePlayersTextDrawSpeed(playerid,bool:info){
	if(info == true){
	    PlayerTextDrawShow(playerid, CarSpeed[playerid]);
        CarSpeed[playerid] = CreatePlayerTextDraw(playerid, 442.399963, 386.026580, "SPEED");
        PlayerTextDrawLetterSize(playerid, CarSpeed[playerid], 0.401249, 1.430832);
        PlayerTextDrawAlignment(playerid, CarSpeed[playerid], 1);
        PlayerTextDrawColor(playerid, CarSpeed[playerid], -1);
        PlayerTextDrawSetShadow(playerid, CarSpeed[playerid], 0);
        PlayerTextDrawSetOutline(playerid, CarSpeed[playerid], 1);
        PlayerTextDrawBackgroundColor(playerid, CarSpeed[playerid], 51);
        PlayerTextDrawFont(playerid, CarSpeed[playerid], 1);
        PlayerTextDrawSetProportional(playerid, CarSpeed[playerid], 1);
	}
	else if(info == false){
	    PlayerTextDrawHide(playerid, CarSpeed[playerid]);
	}
}
public OnPlayerStateChange(playerid, newstate, oldstate){
	if(newstate == PLAYER_STATE_DRIVER)
	{
		if(newstate == PLAYER_STATE_DRIVER)
		{
		    CreatePlayersTextDrawSpeed(playerid,true)
		    SpeedTimer[playerid] = SetTimerEx("UpdateSpeed",200,1,"d",playerid);
		}
		if(oldstate == PLAYER_STATE_DRIVER)
		{
		    CreatePlayersTextDrawSpeed(playerid,false);
		    KillTimer(SpeedTimer[playerid]);
		}
	}
	return 1;
}

public OnPlayerDisconnect(playerid, reason){
	KillTimer(SpeedTimer[playerid]);
	return 1;
}

forward UpdateSpeed(playerid);
public UpdateSpeed(playerid){
	static const fmt_str[] = "%d";
	new string[sizeof(fmt_str)-2+3+1];
	format(string, sizeof(string), fmt_str, SpeedVehicle(playerid));
    PlayerTextDrawSetString(playerid, CarSpeed[playerid], string);
    return 1;
}

stock SpeedVehicle(playerid){
	new Float:ST[4];
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
	else return 0;
	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]);
}

 

Edited by Покемон

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content