03.06.2012, 16:52
eu achei um comando de marcha e qero sabe como poe pra passa em vez de control para 0
PHP код:
#include <a_samp>
#define MaxPlayers 500
new
vTests[MaxPlayers],
TransAtual[MaxPlayers],
Text:KmTrans[MaxPlayers],
Text:OneTrans[MaxPlayers],
Text:TwoTrans[MaxPlayers],
Text:BackTrans[MaxPlayers],
Text:TreeTrans[MaxPlayers],
Text:FourTrans[MaxPlayers],
Text:FiveTrans[MaxPlayers],
Text:VeloTrans[MaxPlayers],
Text:CountTrans[MaxPlayers];
stock SemMarcha(vehicleid)
{
new result;
new model = GetVehicleModel(vehicleid);
switch(model)
{
case 595, 593, 592, 577, 563, 553, 548, 520, 519, 513, 512, 511, 510, 509, 497, 493, 488, 487, 481, 476, 473, 472, 469, 460, 454, 453, 452, 447, 446, 430, 425, 417: result = model;
default: result = 0;
}
return result;
}
enum mInfo { Marcha, Speed };
new MarchaInfo[][mInfo] = { {0,000}, {1,025}, {2,055}, {3,085}, {4,115}, {5,140} };
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) //
public OnPlayerConnect(playerid)
{
BackTrans[playerid] = TextDrawCreate(250.000000, 380.000000, "a");
TextDrawBackgroundColor(BackTrans[playerid], 255);
TextDrawFont(BackTrans[playerid], 1);
TextDrawLetterSize(BackTrans[playerid], 0.000000, 4.000000);
TextDrawColor(BackTrans[playerid], -1);
TextDrawSetOutline(BackTrans[playerid], 0);
TextDrawSetProportional(BackTrans[playerid], 1);
TextDrawSetShadow(BackTrans[playerid], 1);
TextDrawUseBox(BackTrans[playerid], 1);
TextDrawBoxColor(BackTrans[playerid], 255);
TextDrawTextSize(BackTrans[playerid], 358.000000, 140.000000);
OneTrans[playerid] = TextDrawCreate(250.000000, 340.000000, "-");
TextDrawBackgroundColor(OneTrans[playerid], 255);
TextDrawFont(OneTrans[playerid], 1);
TextDrawLetterSize(OneTrans[playerid], 0.200000, 10.799995);
TextDrawColor(OneTrans[playerid], -1);
TextDrawSetOutline(OneTrans[playerid], 0);
TextDrawSetProportional(OneTrans[playerid], 1);
TextDrawSetShadow(OneTrans[playerid], 1);
TwoTrans[playerid] = TextDrawCreate(255.000000, 340.000000, "-");
TextDrawBackgroundColor(TwoTrans[playerid] , 255);
TextDrawFont(TwoTrans[playerid] , 1);
TextDrawLetterSize(TwoTrans[playerid] , 0.200000, 10.799995);
TextDrawColor(TwoTrans[playerid] , -1);
TextDrawSetOutline(TwoTrans[playerid] , 0);
TextDrawSetProportional(TwoTrans[playerid] , 1);
TextDrawSetShadow(TwoTrans[playerid] , 1);
TreeTrans[playerid] = TextDrawCreate(260.000000, 340.000000, "-");
TextDrawBackgroundColor(TreeTrans[playerid], 255);
TextDrawFont(TreeTrans[playerid], 1);
TextDrawLetterSize(TreeTrans[playerid], 0.200000, 10.799995);
TextDrawColor(TreeTrans[playerid], -1);
TextDrawSetOutline(TreeTrans[playerid], 0);
TextDrawSetProportional(TreeTrans[playerid], 1);
TextDrawSetShadow(TreeTrans[playerid], 1);
FourTrans[playerid] = TextDrawCreate(265.000000, 340.000000, "-");
TextDrawBackgroundColor(FourTrans[playerid], 255);
TextDrawFont(FourTrans[playerid], 1);
TextDrawLetterSize(FourTrans[playerid], 0.200000, 10.799995);
TextDrawColor(FourTrans[playerid], -1);
TextDrawSetOutline(FourTrans[playerid], 0);
TextDrawSetProportional(FourTrans[playerid], 1);
TextDrawSetShadow(FourTrans[playerid], 1);
FiveTrans[playerid] = TextDrawCreate(270.000000, 340.000000, "-");
TextDrawBackgroundColor(FiveTrans[playerid], 255);
TextDrawFont(FiveTrans[playerid], 1);
TextDrawLetterSize(FiveTrans[playerid], 0.200000, 10.799995);
TextDrawColor(FiveTrans[playerid], -1);
TextDrawSetOutline(FiveTrans[playerid], 0);
TextDrawSetProportional(FiveTrans[playerid], 1);
TextDrawSetShadow(FiveTrans[playerid], 1);
KmTrans[playerid] = TextDrawCreate(315.000000, 395.000000, "KM/H");
TextDrawBackgroundColor(KmTrans[playerid], 255);
TextDrawFont(KmTrans[playerid], 1);
TextDrawLetterSize(KmTrans[playerid], 0.500000, 1.000000);
TextDrawColor(KmTrans[playerid], -1);
TextDrawSetOutline(KmTrans[playerid], 0);
TextDrawSetProportional(KmTrans[playerid], 1);
TextDrawSetShadow(KmTrans[playerid], 1);
VeloTrans[playerid] = TextDrawCreate(281.000000, 396.000000, "_");
TextDrawBackgroundColor(VeloTrans[playerid], 255);
TextDrawFont(VeloTrans[playerid], 1);
TextDrawLetterSize(VeloTrans[playerid], 0.500000, 1.000000);
TextDrawColor(VeloTrans[playerid], -1);
TextDrawSetOutline(VeloTrans[playerid], 0);
TextDrawSetProportional(VeloTrans[playerid], 1);
TextDrawSetShadow(VeloTrans[playerid], 1);
CountTrans[playerid] = TextDrawCreate(283.000000, 381.000000, "Trans:~r~");
TextDrawBackgroundColor(CountTrans[playerid], 255);
TextDrawFont(CountTrans[playerid], 1);
TextDrawLetterSize(CountTrans[playerid], 0.500000, 1.000000);
TextDrawColor(CountTrans[playerid], -1);
TextDrawSetOutline(CountTrans[playerid], 0);
TextDrawSetProportional(CountTrans[playerid], 1);
TextDrawSetShadow(CountTrans[playerid], 1);
return true;
}
stock LimitarVelocidade(playerid,vAtual,Vid)
{
new mAtual = TransAtual[playerid];
if(vAtual > MarchaInfo[mAtual][Speed] && mAtual != 5)
{
++vTests[playerid];
GameTextForPlayer(playerid,"~r~Cuidado - Troque de Marcha ! Striker Samp",2000,5);
}
if(vTests[playerid] >= 3)
{
vTests[playerid] = 0;
SetVehicleSpeed(Vid,(MarchaInfo[mAtual][Speed] - 5));
}
if(vAtual < MarchaInfo[mAtual][Speed] - 35) --TransAtual[playerid];
if(vAtual == 0) TransAtual[playerid] = 0;
return true;
}
stock AtualizarVelocidade(playerid,vAtual)
{
if(!SemMarcha(playerid) && IsPlayerInAnyVehicle(playerid))
{
new sString[18];
format(sString,18,"~r~%d",vAtual);
TextDrawHideForPlayer(playerid, VeloTrans[playerid]);
TextDrawSetString(VeloTrans[playerid],sString);
TextDrawShowForPlayer(playerid, VeloTrans[playerid]);
}
return true;
}
stock AtualizarMarcha(playerid,number)
{
new
sString[100];
if(IsPlayerInAnyVehicle(playerid))
{
format(sString,18,"Trans:~r~%d",TransAtual[playerid]);
TextDrawHideForPlayer(playerid, CountTrans[playerid]);
TextDrawSetString(CountTrans[playerid],sString);
TextDrawShowForPlayer(playerid, CountTrans[playerid]);
}
if(number == 0)
{
TextDrawHideForPlayer(playerid, OneTrans[playerid]);
TextDrawHideForPlayer(playerid, TwoTrans[playerid]);
TextDrawHideForPlayer(playerid, TreeTrans[playerid]);
TextDrawHideForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
}
if(number == 1)
{
TextDrawShowForPlayer(playerid, OneTrans[playerid]);
TextDrawHideForPlayer(playerid, TwoTrans[playerid]);
TextDrawHideForPlayer(playerid, TreeTrans[playerid]);
TextDrawHideForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
}
if(number == 2)
{
TextDrawShowForPlayer(playerid, OneTrans[playerid]);
TextDrawShowForPlayer(playerid, TwoTrans[playerid]);
TextDrawHideForPlayer(playerid, TreeTrans[playerid]);
TextDrawHideForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
}
if(number == 3)
{
TextDrawShowForPlayer(playerid, OneTrans[playerid]);
TextDrawShowForPlayer(playerid, TwoTrans[playerid]);
TextDrawShowForPlayer(playerid, TreeTrans[playerid]);
TextDrawHideForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
}
if(number == 4)
{
TextDrawShowForPlayer(playerid, OneTrans[playerid]);
TextDrawShowForPlayer(playerid, TwoTrans[playerid]);
TextDrawShowForPlayer(playerid, TreeTrans[playerid]);
TextDrawShowForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
}
if(number == 5)
{
TextDrawShowForPlayer(playerid, OneTrans[playerid]);
TextDrawShowForPlayer(playerid, TwoTrans[playerid]);
TextDrawShowForPlayer(playerid, TreeTrans[playerid]);
TextDrawShowForPlayer(playerid, FourTrans[playerid]);
TextDrawShowForPlayer(playerid, FiveTrans[playerid]);
}
if(number == 10)
{
TextDrawShowForPlayer(playerid, OneTrans[playerid]);
TextDrawShowForPlayer(playerid, TwoTrans[playerid]);
TextDrawShowForPlayer(playerid, TreeTrans[playerid]);
TextDrawShowForPlayer(playerid, FourTrans[playerid]);
TextDrawShowForPlayer(playerid, FiveTrans[playerid]);
}
return true;
}
public OnPlayerUpdate(playerid)
{
if(!IsPlayerInAnyVehicle(playerid))
{
TextDrawHideForPlayer(playerid, BackTrans[playerid]);
TextDrawHideForPlayer(playerid, OneTrans[playerid]);
TextDrawHideForPlayer(playerid, TwoTrans[playerid]);
TextDrawHideForPlayer(playerid, TreeTrans[playerid]);
TextDrawHideForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
TextDrawHideForPlayer(playerid, KmTrans[playerid]);
TextDrawHideForPlayer(playerid, VeloTrans[playerid]);
TextDrawHideForPlayer(playerid, CountTrans[playerid]);
}
if(IsPlayerInAnyVehicle(playerid))
{
new
Vid = GetPlayerVehicleID(playerid),
vAtual = GetPlayerSpeed(playerid,true);
LimitarVelocidade(playerid,vAtual,Vid);
AtualizarVelocidade(playerid,vAtual);
}
if(TransAtual[playerid] < 0) TransAtual[playerid] = 0;
return true;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
TextDrawShowForPlayer(playerid, BackTrans[playerid]);
TextDrawShowForPlayer(playerid, KmTrans[playerid]);
TextDrawShowForPlayer(playerid, VeloTrans[playerid]);
TextDrawShowForPlayer(playerid, CountTrans[playerid]);
}
else
{
TextDrawHideForPlayer(playerid, BackTrans[playerid]);
TextDrawHideForPlayer(playerid, OneTrans[playerid]);
TextDrawHideForPlayer(playerid, TwoTrans[playerid]);
TextDrawHideForPlayer(playerid, TreeTrans[playerid]);
TextDrawHideForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
TextDrawHideForPlayer(playerid, KmTrans[playerid]);
TextDrawHideForPlayer(playerid, VeloTrans[playerid]);
TextDrawHideForPlayer(playerid, CountTrans[playerid]);
}
return true;
}
public OnPlayerExitVehicle(playerid,vehicleid)
{
TextDrawHideForPlayer(playerid, BackTrans[playerid]);
TextDrawHideForPlayer(playerid, OneTrans[playerid]);
TextDrawHideForPlayer(playerid, TwoTrans[playerid]);
TextDrawHideForPlayer(playerid, TreeTrans[playerid]);
TextDrawHideForPlayer(playerid, FourTrans[playerid]);
TextDrawHideForPlayer(playerid, FiveTrans[playerid]);
TextDrawHideForPlayer(playerid, KmTrans[playerid]);
TextDrawHideForPlayer(playerid, VeloTrans[playerid]);
TextDrawHideForPlayer(playerid, CountTrans[playerid]);
TransAtual[vehicleid] = 0;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(SemMarcha(GetPlayerVehicleID(playerid)))
{
new sString[50];
TransAtual[playerid] = 10;
TextDrawHideForPlayer(playerid, VeloTrans[playerid]);
format(sString,50,"~r~Auto");
TextDrawSetString(VeloTrans[playerid],sString);
}
if (newkeys & KEY_FIRE && IsPlayerInAnyVehicle(playerid) && !SemMarcha(GetPlayerVehicleID(playerid))) TransAtual[playerid]++ ;
if(TransAtual[playerid] > 5 && IsPlayerInAnyVehicle(playerid) && !SemMarcha(GetPlayerVehicleID(playerid))) TransAtual[playerid] = 5;
AtualizarMarcha(playerid, TransAtual[playerid]) ;
return true;
}
public OnPlayerEnterVehicle(playerid,vehicleid)
{
if(SemMarcha(GetPlayerVehicleID(playerid)))
{
new sString[50];
TransAtual[playerid] = 10;
TextDrawHideForPlayer(playerid, VeloTrans[playerid]);
format(sString,50,"~r~Auto");
TextDrawSetString(VeloTrans[playerid],sString);
}
return 1;
}
stock GetPlayerSpeed(playerid,bool:kmh)//by misco
{
new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz);
rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}
stock SetVehicleSpeed ( vehicleid , Float:speed , mode = 1 ) //
{
new Float:vAngle;
GetVehicleZAngle ( vehicleid , vAngle ) ;
speed = ( ( !mode ) ? ( floatdiv ( speed, 105.0 ) ) : ( floatdiv ( speed, 170.0 ) ) );
return SetVehicleVelocity ( vehicleid , speed * floatsin ( -vAngle , degrees ) , speed * floatcos ( -vAngle , degrees ) , 0.0 ) ;
}