24.11.2012, 02:16
Ok I have been having serious problems with keys in my GM.
The problem is is that it doesn't work right, If I'm in a car it uses the Default onfoot key EVEN though I'm in a car (and somtimes it doesn't even work at all! This is very frustrating. I am a newer scripter so I have no idea what could be wrong
PLEASE help me. I usually Rep those who can help me (for those who care).
Thanks: jakejohnsonusa
Here is an example of a key command I am having problems with:
**In this case it doesn't always start with the Handbrake in vehicle key (space), but it usually works with the Aim Key (right click)**
Note: I DON't Need the link to GetPlayerKeys I've read that!
The problem is is that it doesn't work right, If I'm in a car it uses the Default onfoot key EVEN though I'm in a car (and somtimes it doesn't even work at all! This is very frustrating. I am a newer scripter so I have no idea what could be wrong
PLEASE help me. I usually Rep those who can help me (for those who care).
Thanks: jakejohnsonusa
Here is an example of a key command I am having problems with:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new string[128];
new sendername[MAX_PLAYER_NAME];
new pveh = GetVehicleModel(GetPlayerVehicleID(playerid));
new newcar = GetPlayerVehicleID(playerid);
new gun1 = GetPlayerWeapon(playerid);
new gunname1[24];
GetWeaponName(gun1,gunname1,sizeof(gunname1));
if ( PRESSED(KEY_SUBMISSION) ) //light system
{
if (IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return 1;
{
ToggleVehicleLights(newcar)
}
}
}
if (newkeys & HANDBRAKE )
{
if(IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerConnected(playerid))
{
new idcar = GetPlayerVehicleID(playerid);
if(gEngine[idcar] == 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
if(IsARentableCar(idcar))
{
if(HireCar[playerid] != idcar) return 1;
}
if(IsAHarvest(idcar)) return 1;
if(IsADrugHarvest(idcar)) return 1;
if(IsASweeper(idcar)) return 1;
if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
return SendClientMessage(playerid, COLOR_GREY,"* You cannot turn this car's engine!");
format(string, sizeof(string), "* %s spins a key and tries to start vehicle engine.", sendername);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
gEngine[idcar] = 1;
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, 0, 0, 0, 0, 0);
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
CommandLog(string);
return 1;
}
}
}
}
Note: I DON't Need the link to GetPlayerKeys I've read that!