Need help with cruisecontrol
#1

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?
Reply
#2

use public OnPlayerStateChange
Reply
#3

I've never heard of that callback
Reply
#4

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#5

Looks pretty hard i don't understand it .
Reply
#6

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)
Reply
#7

The key list:
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Reply
#8

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;

Reply
#9

That code doesnt work, when your in a vehicle and /cruise the vehicle wont continue moving.
Reply
#10

u need to use a timer, when u type /cruise now, it will only set your vehicle velocity once...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)