SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/05/2016, 12:31 PM   #1
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,918
Reputation: 258
Default Boosting a vehicle?

Hello there!
I want to create a "booster". When the player press Y, his speed is boosted.
What is the problem? The problem is when I set the vehicle's velocity.
Take a look : SetVehicleVelocity(GetPlayerVehicleID(playerid), x+0.5, y+0.5, z);
This depending which direction the driver is driving (I hope this means something). :/
So how can I solve the problem?

PHP Code:
    if((newkeys KEY_YES) && (oldkeys KEY_SPRINT) && IsPlayerInAnyVehicle(playerid))
    {
         new 
Float:xFloat:yFloat:z;
        
SendClientMessage(playerid, -1"Boosting ...");
        
GetVehicleVelocity(GetPlayerVehicleID(playerid), xyz);
        
SetVehicleVelocity(GetPlayerVehicleID(playerid), x+0.5y+0.5z);
        return 
1;
    } 
Dayrion is offline   Reply With Quote
Old 05/05/2016, 12:49 PM   #2
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,831
Reputation: 114
Default Re: Boosting a vehicle?

Because the vehicle can be travelling South-West aswell, which results in negative X and Y speeds, so multiply it instead:
Code:
SetVehicleVelocity(GetPlayerVehicleID(playerid), x*0.5, y*0.5, z);
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Old 05/05/2016, 12:59 PM   #3
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,918
Reputation: 258
Default Re: Boosting a vehicle?

Oh.. I didn't think this way... So basic.. x)
Thanks'!

NB : x1.5 because x0.5 is like x/2. :P
Dayrion is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] tAxI's Xtreme Vehicle Management - Advanced Vehicle Ownership and Administration Menu CJay9209 Filterscripts 13 16/10/2015 07:21 AM
Remove the speed boosting on bikes! brianvis Server Support 2 28/09/2013 06:43 PM
How can i make boosting ? DonBonanno Scripting Help 1 24/04/2013 05:22 AM
Boosting help Vasu99 Scripting Help 11 21/09/2012 09:59 AM
Boosting WI-FI Strength/Range Mrkrabz Everything and Nothing 10 27/10/2009 07:04 PM


All times are GMT. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.