03.07.2012, 06:48
Hey,
I made a few textdraws, for fuel speed and some others,
But in the begin when it preshed MMB and im not close enough to a player it shows the correct textdraw, but if I do it now it shows "Fuel: 100"
Same with my speedo, it doesn't come up but in the begin it did!
Tell me if you know how to solve this problem
I made a few textdraws, for fuel speed and some others,
But in the begin when it preshed MMB and im not close enough to a player it shows the correct textdraw, but if I do it now it shows "Fuel: 100"
Same with my speedo, it doesn't come up but in the begin it did!
Tell me if you know how to solve this problem
pawn Код:
new Text:NotCar;
new Text:NotRob;
new Text:tengine;
new Text:tlight;
new Text:td_fuel[MAX_PLAYERS];
new Text:speed[MAX_PLAYERS];
//Ongamemodeinit
NotRob = TextDrawCreate(217.000000, 340.000000, "You are not close enough to another player!");
TextDrawBackgroundColor(NotRob, 255);
TextDrawFont(NotRob, 1);
TextDrawLetterSize(NotRob, 0.539999, 1.600000);
TextDrawColor(NotRob, -1);
TextDrawSetOutline(NotRob, 1);
TextDrawSetProportional(NotRob, 1);
NotCar = TextDrawCreate(218.000000, 340.000000, "You are not authorized to use this vehicle!");
TextDrawBackgroundColor(NotCar, 255);
TextDrawFont(NotCar, 1);
TextDrawLetterSize(NotCar, 0.539999, 1.600000);
TextDrawColor(NotCar, -1);
TextDrawSetOutline(NotCar, 1);
TextDrawSetProportional(NotCar, 1);
tengine = TextDrawCreate(7.000000, 306.000000, "Type /e to turn on the engine.");
TextDrawBackgroundColor(tengine, 255);
TextDrawFont(tengine, 1);
TextDrawLetterSize(tengine, 0.529999, 1.700000);
TextDrawColor(tengine, -1);
TextDrawSetOutline(tengine, 1);
TextDrawSetProportional(tengine, 1);
tlight = TextDrawCreate(7.000000, 323.000000, "Type /l to turn on the lights.");
TextDrawBackgroundColor(tlight, 255);
TextDrawFont(tlight, 1);
TextDrawLetterSize(tlight, 0.529900, 1.500000);
TextDrawColor(tlight, -1);
TextDrawSetOutline(tlight, 1);
TextDrawSetProportional(tlight, 1);
//Onplayerconnect
speed[playerid] = TextDrawCreate(485.000000, 370.000000, "_");
TextDrawBackgroundColor(speed[playerid], 255);
TextDrawFont(speed[playerid], 1);
TextDrawLetterSize(speed[playerid], 0.500000, 1.800000);
TextDrawColor(speed[playerid], -1);
TextDrawSetOutline(speed[playerid], 1);
TextDrawSetProportional(speed[playerid], 1);
td_fuel[playerid] = TextDrawCreate(485.000000, 390.000000, "_");
TextDrawBackgroundColor(td_fuel[playerid], 255);
TextDrawFont(td_fuel[playerid], 1);
TextDrawLetterSize(td_fuel[playerid], 0.500000, 1.800000);
TextDrawColor(td_fuel[playerid], -1);
TextDrawSetOutline(td_fuel[playerid], 1);
TextDrawSetProportional(td_fuel[playerid], 1);
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
{
new PlayerVehicle = GetPlayerVehicleID(playerid);
if(Vehicle[PlayerVehicle][CopCar] != 0 && Vehicle[PlayerVehicle][CopCar] != Player[playerid][Cop])
{
TextDrawShowForPlayer(playerid, Text:NotCar);
RemovePlayerFromVehicle(playerid);
SetTimerEx("Removenotcarwindow", 3000, false, "d", playerid);
}
}
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
{
}
if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new vid = GetPlayerVehicleID(playerid);
new string[125];
fueltimer = SetTimer("timer_fuel_lower",5000,true);
speedtimer = SetTimer("Speedometer", 100, true);
format(string,sizeof string,"Fuel: %i",fuel[vid]);
TextDrawSetString(td_fuel[playerid],string);
TextDrawShowForPlayer(playerid,td_fuel[playerid]);
TextDrawShowForPlayer(playerid,speed[playerid]);
TextDrawShowForPlayer(playerid,tengine);
TextDrawShowForPlayer(playerid,tlight);
SetTimerEx("Removetypewindow", 2000, false, "d", playerid);
}
else
{
KillTimer(fueltimer);
KillTimer(speedtimer);
TextDrawHideForPlayer(playerid,td_fuel[playerid]);
TextDrawHideForPlayer(playerid,speed[playerid]);
TextDrawHideForPlayer(playerid,tengine);
TextDrawHideForPlayer(playerid,tlight);
}
return 1;
}
stock GetPlayerSpeed(playerid, get3d)
{
new Float:x, Float:y, Float:z;
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
else
GetPlayerVelocity(playerid, x, y, z);
return SpeedCheck(x, y, z, 100.0, get3d);
}
public Speedometer(playerid)
{
new string[60];
format(string, sizeof(string), "Speed: %d KM/H", GetPlayerSpeed(playerid, 0));
TextDrawSetString(speed[playerid], string);
return 1;
}
//Onplayerkeystatechange
if (newkeys & KEY_LOOK_BEHIND)
{
new NearestPlayer = GetClosestPlayer(playerid);
if(Player[playerid][Civilian] == 1 || Player[playerid][Criminal] == 1)
{
if(GetDistanceBetweenPlayers(NearestPlayer, playerid) < 4)
{
if(HasRobbedRecently[playerid] >= 1)
{
SendClientMessage(playerid, RED, "You are too tired from the last person you robbed. Please wait before robbing again.");
}
else
{
if(GetPlayerMoney(NearestPlayer) == 0)
{
SCM(playerid, RED, "This player is poor, he doesn't have money!");
}
else
{
new mrand =random(GetPlayerMoney(NearestPlayer)/2), string[128];
format(string,sizeof(string),"You have robbed $%d from %s(%d)",mrand,GetName(NearestPlayer),NearestPlayer);
SendClientMessage(playerid, GREEN, string);
GivePlayerMoney(playerid,mrand);
GivePlayerMoney(NearestPlayer, -mrand);
Player[playerid][Money] += mrand;
Player[NearestPlayer][Money] -= mrand;
IncreaseWantedLevel(playerid, 1);
Player[playerid][Wantedlvl] += 1;
IncreasePlayerScore(playerid, 2);
Player[playerid][Score] += 2;
Player[playerid][Civilian] = 0;
Player[playerid][Criminal] = 1;
format(string,sizeof(string),"%s robbed $%d from you!",GetName(playerid), mrand);
SendClientMessage(NearestPlayer, RED, string);
HasRobbedRecently[playerid] = 99;
SetTimerEx("RobbingPlayer", 120000, false, "d", playerid);
}
}
}
else
{
TextDrawShowForPlayer(playerid, Text:NotRob);
SetTimerEx("Removenotrobwindow", 3500, false, "d", playerid);
}
}
if(Player[playerid][Cop] == 1)
{
if(GetDistanceBetweenPlayers(NearestPlayer, playerid) < 4)
{
if(Player[NearestPlayer][Criminal] == 1)
{
CuffingPlayer[playerid] = 5;
SetTimerEx("CuffPlayer", 5000, false, "d", playerid);
}
}
else
{
TextDrawShowForPlayer(playerid, Text:NotRob);
SetTimerEx("Removenotrobwindow", 3500, false, "d", playerid);
}
}
}