SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 22/12/2019, 08:34 PM   #1
maikons
Gangsta
 
Join Date: Jun 2013
Posts: 545
Reputation: 6
Default Re-enter a car window after drive-bying

How to re-enter a car window after drive-bying?

I played a server with this feature... How to do it?

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
pawn Code:
// re-enter vehicle window
                else if(GetPlayerState(id) == PLAYER_STATE_PASSENGER)
                {
                    if(newkeys & KEY_HORN)
                    {
                        // ?
                    }
                }
__________________
maikons is offline   Reply With Quote
Old 22/12/2019, 10:13 PM   #2
IzadorO
Huge Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 204
Reputation: 17
Default Re: Re-enter a car window after drive-bying

Code:
#define DOUBLE_CLICK_TIME 1500
#define REARMED_WEAPON_UPDATES 4

new
    g_TickPushed[MAX_PLAYERS],
    g_Count[MAX_PLAYERS],
    g_Weapon[MAX_PLAYERS];

under OnPlayerKeyStateChange

                if (GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
		{
		    if (newkeys & KEY_CROUCH)
			{
				if (GetTickCount() - g_TickPushed[playerid] < DOUBLE_CLICK_TIME)
				{
				    g_Weapon[playerid] = GetPlayerWeapon(playerid);
		            g_Count[playerid] = REARMED_WEAPON_UPDATES;
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            SetPlayerArmedWeapon(playerid, 0);
				}
				g_TickPushed[playerid] = GetTickCount();
			}
		}

under OnPlayerUpdate
if(g_Count[playerid])
	{
        if(--g_Count[playerid] == 0)
		{
                SetPlayerArmedWeapon(playerid, g_Weapon[playerid]);
        }
    }
I believe that's all of it, found it in my script. I believe it was originally created by Emmet, here https://forum.sa-mp.com/showthread.php?t=489907

With this you press H to lean back inside, and you can lean out again. The indentations will need fixed as this has just been pasted straight from my script.
__________________
IzadorO is offline   Reply With Quote
Old 23/12/2019, 08:43 PM   #3
maikons
Gangsta
 
Join Date: Jun 2013
Posts: 545
Reputation: 6
Default Re: Re-enter a car window after drive-bying

Quote:
Originally Posted by IzadorO View Post
Code:
#define DOUBLE_CLICK_TIME 1500
#define REARMED_WEAPON_UPDATES 4

new
    g_TickPushed[MAX_PLAYERS],
    g_Count[MAX_PLAYERS],
    g_Weapon[MAX_PLAYERS];

under OnPlayerKeyStateChange

                if (GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
		{
		    if (newkeys & KEY_CROUCH)
			{
				if (GetTickCount() - g_TickPushed[playerid] < DOUBLE_CLICK_TIME)
				{
				    g_Weapon[playerid] = GetPlayerWeapon(playerid);
		            g_Count[playerid] = REARMED_WEAPON_UPDATES;
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            ApplyAnimation(playerid, "PED", "facanger", 4.1, 0, 1, 1, 1, 1, 1);
		            SetPlayerArmedWeapon(playerid, 0);
				}
				g_TickPushed[playerid] = GetTickCount();
			}
		}

under OnPlayerUpdate
if(g_Count[playerid])
	{
        if(--g_Count[playerid] == 0)
		{
                SetPlayerArmedWeapon(playerid, g_Weapon[playerid]);
        }
    }
I believe that's all of it, found it in my script. I believe it was originally created by Emmet, here https://forum.sa-mp.com/showthread.php?t=489907

With this you press H to lean back inside, and you can lean out again. The indentations will need fixed as this has just been pasted straight from my script.
THANK YOU so much to try to help me
but i test it here and just don't work, did u test it?
i'm sorry i don't understood your code, it's not you, its me

what is this stuff on onplayerupdate (i put it there, i just don't know what is it)?
__________________
maikons is offline   Reply With Quote
Old 23/12/2019, 11:31 PM   #4
IzadorO
Huge Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 204
Reputation: 17
Default Re: Re-enter a car window after drive-bying

Can you send the errors and the areas of your script containing the code I sent you? It's not my code, it was originally created by Emmet I believe however it was published here on these forums.

OnPlayerUpdate is called roughly every 20 - 40 milliseconds I believe. The code for that is simply checking if g_Count has been set, taking away from it until it reaches 0 before setting the player's armed weapon to their previous weapon, thus allowing them to drive by again.
__________________
IzadorO is offline   Reply With Quote
Old 24/12/2019, 12:16 AM   #5
BreezeSAMP
Little Clucker
 
Join Date: Dec 2018
Location: Spain
Posts: 21
Reputation: 11
Default Re: Re-enter a car window after drive-bying

pawn Code:
#define funcion%0(%1)                       forward %0(%1); public %0(%1)


cmd:drivebug(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SMC(playerid, -1, "You are not in any vehicle.");
    if(GetPlayerState(playerid) != PLAYER_STATE_PASSENGER) return _Mensaje(playerid, -1, "You are not as a passenger.");
    ApplyAnimation(playerid, "PED", "CAR_GETIN_RHS", 4.1, 0, 0, 0, 0, 1, 1);
    SetPlayerArmedWeapon(playerid, 0);
        SetTimerEx("desbugdrive", 500, false, "ii", playerid, GetPlayerWeapon(playerid));
        return 1;
}

funcion desbugdrive(playerid, arma)
{
    SetPlayerArmedWeapon(playerid, arma);
}
CREDITS: Mugsy
BreezeSAMP is offline   Reply With Quote
Old 24/12/2019, 06:42 PM   #6
maikons
Gangsta
 
Join Date: Jun 2013
Posts: 545
Reputation: 6
Default Re: Re-enter a car window after drive-bying

now i got the point, it set the weapon armed to 0, and give it back
thank you both
i rep u both
__________________
maikons 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
Hello i want /enter and /exit used whit [ F Or Enter ] For enter to house or biz rezapalang Scripting Help 5 10/04/2017 05:51 AM
Enter more vehicle to drive. Mey6155 Scripting Help 2 27/05/2014 02:54 PM
[Tutorial] /enter -- Making a simple enter command. EvanA Tutorials 7 17/11/2013 05:54 PM
Why I can't drive or enter tram? kbalor Scripting Help 7 23/08/2012 01:57 PM
how to create an /exit and /enter command to enter an costum interior? sandisk125 Help Archive 5 18/08/2009 02:07 PM


All times are GMT. The time now is 12:55 AM.


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