SA-MP Forums Archive
Need help with cruisecontrol - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with cruisecontrol (/showthread.php?tid=280930)



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(playeridnewkeysoldkeys)
{
    if(
PRESSED(KEY_SECONDARY_ATTACK))
    {
        new 
Float:vXFloat:vYFloat:vZ;
        
GetVehicleVelocity(GetPlayerVehicleID(playerid), vXvYvZ);
        
SetVehicleVelocity(GetPlayerVehicleID(playerid), vXvYvZ);
        
SendClientMessage(playeridCOLOR_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...