Need help with cruisecontrol -
dahley5 - 03.09.2011
Hey all! I made a cruise control script for my server, it looks like this:
pawn Код:
if (strcmp("/cruise", cmdtext, true, 10) == 0)
{
new Float:vX, Float:vY, Float:vZ;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
SetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
SendClientMessage(playerid, COLOR_ORANGE,"Cruise control has been enabled!");
return 1;
}
return 0;
Now what i want to do is change it to like that instead of typing /cruise you do lctrl, (attack button).
Does anyone know how?
Re : Need help with cruisecontrol -
Naruto_Emilio - 03.09.2011
use public OnPlayerStateChange
Re: Need help with cruisecontrol -
dahley5 - 03.09.2011
I've never heard of that callback
Re: Need help with cruisecontrol -
=WoR=Varth - 03.09.2011
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Re: Need help with cruisecontrol -
dahley5 - 03.09.2011
Looks pretty hard

i don't understand it

.
Re: Need help with cruisecontrol -
Improvement™ - 03.09.2011
Quote:
Originally Posted by dahley5
Looks pretty hard  i don't understand it  .
|
Just take a close look at the examples on that page, try going from step to step, if you understand the first step, you go and check if you understand the second step, if you don't understand the second step, you reread the second step untill you get it, and so on. Its really not that complicated trust me.
Perhaps take a look at this example:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_JUMP || newkeys & KEY_SPRINT)
{
if(PlayerJustConnected[playerid] && IsPlayerLogged[playerid])
{
DisplayDialogForPlayer(playerid, TEAMSELECTION);
}
}
}
(Quote from my gamemode)
Re: Need help with cruisecontrol -
=WoR=Varth - 03.09.2011
The key list:
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Re: Need help with cruisecontrol -
Jafet_Macario - 03.09.2011
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_SECONDARY_ATTACK))
{
new Float:vX, Float:vY, Float:vZ;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
SetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
SendClientMessage(playerid, COLOR_ORANGE,"Cruise control has been enabled!");
}
return 1;
}
Re: Need help with cruisecontrol -
SantarioLeone - 03.09.2011
That code doesnt work, when your in a vehicle and /cruise the vehicle wont continue moving.
Re: Need help with cruisecontrol -
knackworst - 03.09.2011
u need to use a timer, when u type /cruise now, it will only set your vehicle velocity once...