04.03.2014, 21:31
Try this :
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_PASSENGER)
{
SetPlayerArmedWeapon(playerid,0);
}
if(newstate == PLAYER_STATE_PASSENGER)
{
if(newstate == PLAYER_STATE_PASSENGER)
{
new gun,tmp;
GetPlayerWeaponData(playerid,4,gun,tmp);
#pragma unused tmp
if(gun)SetPlayerArmedWeapon(playerid,gun);
else SetPlayerArmedWeapon(playerid,0);
}
}
new str[50];
new vid = GetPlayerVehicleID(playerid);
format(str, sizeof(str), "Vehicle: ~g~%s", CarName[GetVehicleModel(vid)-400]);
speedo1[playerid] = TextDrawCreate(470.0, 390.0, " ");
TextDrawSetString(speedo1[playerid], str);
TextDrawSetShadow(speedo1[playerid], false);
TextDrawSetOutline(speedo1[playerid], 1);
TextDrawLetterSize(speedo1[playerid], TEXT_DRAW_X_FACTOR, TEXT_DRAW_Y_FACTOR);
TextDrawSetProportional(speedo1[playerid], 1);
TextDrawFont(speedo1[playerid], TEXT_DRAW_FONT);
TextDrawShowForPlayer(playerid, speedo1[playerid]);
new Float:vh;
GetVehicleHealth(vid, vh);
new h = floatround(vh) / 10;
format(str, sizeof(str), "Health: ~g~%d \%", h);
speedo2[playerid] = TextDrawCreate(470.0, 400.0, " ");
TextDrawSetString(speedo2[playerid], str);
TextDrawSetShadow(speedo2[playerid], false);
TextDrawSetOutline(speedo2[playerid], 1);
TextDrawLetterSize(speedo2[playerid], TEXT_DRAW_X_FACTOR, TEXT_DRAW_Y_FACTOR);
TextDrawSetProportional(speedo2[playerid], 1);
TextDrawFont(speedo2[playerid], TEXT_DRAW_FONT);
TextDrawShowForPlayer(playerid, speedo2[playerid]);
format(str, sizeof(str), "Fuel: ~g~%d \%", Fuel[GetPlayerVehicleID(playerid)]);
speedo4[playerid] = TextDrawCreate(470.0, 410.0, " ");
TextDrawSetString(speedo4[playerid], str);
TextDrawSetShadow(speedo4[playerid], false);
TextDrawSetOutline(speedo4[playerid], 1);
TextDrawLetterSize(speedo4[playerid], TEXT_DRAW_X_FACTOR, TEXT_DRAW_Y_FACTOR);
TextDrawSetProportional(speedo4[playerid], 1);
TextDrawFont(speedo4[playerid], TEXT_DRAW_FONT);
TextDrawShowForPlayer(playerid, speedo4[playerid]);
new Float:s = GetSpeed(playerid);
new ss = floatround(s);
format(str, sizeof(str), "Speed: ~%s~%d km/h", DamageColor(h), ss);
speedo3[playerid] = TextDrawCreate(470.0, 420.0, " ");
TextDrawSetString(speedo3[playerid], str);
TextDrawSetShadow(speedo3[playerid], false);
TextDrawSetOutline(speedo3[playerid], 1);
TextDrawLetterSize(speedo3[playerid], TEXT_DRAW_X_FACTOR, TEXT_DRAW_Y_FACTOR);
TextDrawSetProportional(speedo3[playerid], 1);
TextDrawFont(speedo3[playerid], TEXT_DRAW_FONT);
TextDrawShowForPlayer(playerid, speedo3[playerid]);
format(str, sizeof(str), "Engine: ~g~%s",EngineEngine(playerid));
speedo5[playerid] = TextDrawCreate(470.0, 430.0, " ");
TextDrawSetString(speedo5[playerid], str);
TextDrawSetShadow(speedo5[playerid], false);
TextDrawSetOutline(speedo5[playerid], 1);
TextDrawLetterSize(speedo5[playerid], TEXT_DRAW_X_FACTOR, TEXT_DRAW_Y_FACTOR);
TextDrawSetProportional(speedo5[playerid], 1);
TextDrawFont(speedo5[playerid], TEXT_DRAW_FONT);
TextDrawShowForPlayer(playerid, speedo5[playerid]);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PlayerPos[0][playerid] = x;
PlayerPos[1][playerid] = y;
PlayerPos[2][playerid] = z;
}
if (newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_ONFOOT ) {
TextDrawHideForPlayer(playerid, speedo1[playerid]);
TextDrawHideForPlayer(playerid, speedo2[playerid]);
TextDrawHideForPlayer(playerid, speedo3[playerid]);
TextDrawHideForPlayer(playerid, speedo4[playerid]);
TextDrawHideForPlayer(playerid, speedo5[playerid]);
}
// if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(!engine) SendClientMessage(playerid, COLOR_WHITE, "You can start or stop the vehicle's engine using {FF6347}/engine{FFFFFF}.");
if(!engine) GameTextForPlayer(playerid, "~w~/engine to turn on/off the vehicle engine.", 3500, 3);
//if(!PlayerInfo[playerid][pCarLic]) SendClientMessage(playerid, COLOR_LIGHTRED, " You don't have a drivers license, beware of cops.");
//if(IsATowTruck(vehicleid)) SendClientMessage(playerid, COLOR_WHITE, "You can tow a vehicle using {FF6347}/tow{FFFFFF}.");
}
return 1;
}