SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 09/06/2012, 09:58 AM   #1
mickos
Gangsta
 
mickos's Avatar
 
Join Date: Apr 2012
Location: Slijterij
Posts: 557
Reputation: 746
Default topic can delete

topic can delete

Last edited by mickos; 09/06/2012 at 11:37 AM.
mickos is offline   Reply With Quote
Old 09/06/2012, 10:00 AM   #2
[KHK]Khalid
Gangsta
 
[KHK]Khalid's Avatar
 
Join Date: Jan 2012
Location: Alexandria, Egypt
Posts: 855
Reputation: 136
Default Re: [Question] stop vehicle

http://wiki.sa-mp.com/wiki/Function:...erControllable .
[KHK]Khalid is offline   Reply With Quote
Old 09/06/2012, 10:02 AM   #3
mickos
Gangsta
 
mickos's Avatar
 
Join Date: Apr 2012
Location: Slijterij
Posts: 557
Reputation: 746
Default Re: [Question] stop vehicle

Hmm not where i looking for, I mean a player press capslock, and than the vehicle stop,
mickos is offline   Reply With Quote
Old 09/06/2012, 10:08 AM   #4
[KHK]Khalid
Gangsta
 
[KHK]Khalid's Avatar
 
Join Date: Jan 2012
Location: Alexandria, Egypt
Posts: 855
Reputation: 136
Default Re: [Question] stop vehicle

TogglePlayerControllable will freeze the player and stop his vehicle (if he's in one). Seems like you want the whole code, don't you?


Edit:

You also may declare a timer (like 500 ms) after you freeze the player (to stop his vehicle) to unfreeze him, if you want only the vehicle to be stopped.

Second-Edit: or just use http://wiki.sa-mp.com/wiki/SetVehicleVelocity
[KHK]Khalid is offline   Reply With Quote
Old 09/06/2012, 10:37 AM   #5
mickos
Gangsta
 
mickos's Avatar
 
Join Date: Apr 2012
Location: Slijterij
Posts: 557
Reputation: 746
Default topic can delete

topic can delete

Last edited by mickos; 09/06/2012 at 11:37 AM.
mickos is offline   Reply With Quote
Old 09/06/2012, 10:47 AM   #6
[KHK]Khalid
Gangsta
 
[KHK]Khalid's Avatar
 
Join Date: Jan 2012
Location: Alexandria, Egypt
Posts: 855
Reputation: 136
Default Re: [Question] stop vehicle

read the example in this page.
[KHK]Khalid is offline   Reply With Quote
Old 09/06/2012, 10:55 AM   #7
mickos
Gangsta
 
mickos's Avatar
 
Join Date: Apr 2012
Location: Slijterij
Posts: 557
Reputation: 746
Default topic can delete

topic can delete

Last edited by mickos; 09/06/2012 at 11:37 AM.
mickos is offline   Reply With Quote
Old 09/06/2012, 11:05 AM   #8
BlackBank
Gangsta
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 523
Reputation: 437
Default Re: [Question] stop vehicle

Quote:
Originally Posted by HellSphinX View Post
TogglePlayerControllable will freeze the player and stop his vehicle (if he's in one). Seems like you want the whole code, don't you?


Edit:

You also may declare a timer (like 500 ms) after you freeze the player (to stop his vehicle) to unfreeze him, if you want only the vehicle to be stopped.

Second-Edit: or just use http://wiki.sa-mp.com/wiki/SetVehicleVelocity
Why you want to use TogglePlayerControllable for it? You know that if you freeze a player, the vehicle is still going forward... So the best way to stop a vehicle, is using SetVehicleVelocity...

EDIT:
Try this code:
pawn Code:
#define FILTERSCRIPT
#include <a_samp>

#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Stop vehicle by Example 0.3");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return 1;
        new
            Float:X,
            Float:Y,
            Float:Z,
            VehicleID = GetPlayerVehicleID(playerid);
        GetVehicleVelocity(VehicleID, X, Y, Z);
        SetVehicleVelocity(VehicleID, -X, -Y, -Z);
    }
    return 1;
}
#endif
BlackBank is offline   Reply With Quote
Old 09/06/2012, 11:05 AM   #9
[KHK]Khalid
Gangsta
 
[KHK]Khalid's Avatar
 
Join Date: Jan 2012
Location: Alexandria, Egypt
Posts: 855
Reputation: 136
Default Re: [Question] stop vehicle

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH))
    {
        if(IsPlayerInAnyVehicle(playerid)) // checks if playrid in a vehicle
        {
            new
                Float:x,
                Float:y,
                Float:z,
                playerveh = GetPlayerVehicleID(playerid); // gets the id of the player's vehicle and store it into playerveh so we can use it in Get/SetVehiclePos
                GetVehiclePos(playerveh, x, y, z);
                SetVehiclePos(playerveh, x, y, z + 2.0);
        }
    }
    return 1;
}


Edit:

Quote:
Originally Posted by BlackBank3 View Post
Why you want to use TogglePlayerControllable for it? You know that if you freeze a player, the vehicle is still going forward... So the best way to stop a vehicle, is using SetVehicleVelocity...
No, the vehicle won't go forward actually it will stop (That's tested).
[KHK]Khalid is offline   Reply With Quote
Old 09/06/2012, 11:13 AM   #10
FalconX
Gangsta
 
FalconX's Avatar
 
Join Date: Mar 2011
Location: Kuwait
Posts: 633
Reputation: 103
Default Re: [Question] stop vehicle

Quote:
Originally Posted by HellSphinX View Post
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH))
    {
        if(IsPlayerInAnyVehicle(playerid)) // checks if playrid in a vehicle
        {
            new
                Float:x,
                Float:y,
                Float:z,
                playerveh = GetPlayerVehicleID(playerid); // gets the id of the player's vehicle and store it into playerveh so we can use it in Get/SetVehiclePos
                GetVehiclePos(playerveh, x, y, z);
                SetVehiclePos(playerveh, x, y, z + 2.0);
        }
    }
    return 1;
}


Edit:



No, the vehicle won't go forward actually it will stop (That's tested).
It's strange, why are you setting vehicle pos? if you want to stop the vehicle you could just stop the engine... SetVehicleParamsForPlayer.

-FalconX
__________________
^
FalconX 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
Stop Vehicle nutzkung69 Scripting Help 0 11/03/2012 11:42 AM
Stop player exiting a Vehicle sNaq Scripting Help 2 14/11/2011 02:18 AM
stop player from driving vehicle park4bmx Help Archive 10 16/04/2011 10:31 PM
How To - Stop Entering Vehicle While Surfing Bug StrickenKid Help Archive 12 24/02/2010 05:46 PM


All times are GMT. The time now is 05:05 PM.


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