Vehicle mod shop, i can exit my vehicle...
#1

Ok I have been up all night and my brain is frazzled..

I'm using 0.3x and on my server I can exit my vehicle in the mod shop, which then makes the menu un usable, which then means i am stuck in the mod shop and for some reason i can't even get into my car again, how can i stop the player being able to leave the vehicle whilst he/she is in the mod shop?

Here is my code for the entering/exiting vehicle on the secondary attack

Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			RemoveDriverFromVehicle(playerid);
			if(engine[GetPlayerVehicleID(playerid)] == 0)
	        {
	            RemoveDriverFromVehicle(playerid);
	            if(PlayerInfo[playerid][pCarlic] == 0)
	            {
	                SetPlayerDrunkLevel (playerid, 0);
			}
	            }
	        }
I know this is simple as hell but I am so tired and just want it fixed before I go to sleep lol! Spent all night scripting and now this little problem is really annoying me haha!

Here is also my OnModShop code..

Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    new vehicle = GetPlayerVehicleID(playerid);
    if(InModShop[playerid] == 1)
	{
	    SetVehiclePos(vehicle, modx[playerid], mody[playerid], modz[playerid]);
	    SetPlayerPos(playerid, modx[playerid], mody[playerid], modz[playerid]);
	    SetPlayerInterior(playerid, 0);
	}
	return 1;
}
Код:
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
	new vehicle = GetPlayerVehicleID(playerid);
	if(enterexit == 1)
	{
		GetVehiclePos(vehicle, modx[playerid], mody[playerid], modz[playerid]);
		InModShop[playerid] = 1;
	}
	if(enterexit == 0)
	{
	    SetVehiclePos(vehicle, modx[playerid], mody[playerid], modz[playerid]);
	    InModShop[playerid] = 0;
	}
	return 1;
}
This is probably the lamest question I have had to ask on the forums but please allow me some credit for being up over 40+ hours lol..

Any help is muchly appreciated!
Reply
#2

you can use TogglePlayerControllable for that.
I would use, in your case, TogglePlayerControllable(playerid,0); when the player enters the modshop, and TogglePlayerControllable(playerid,1); when the player exits it.
Here's some more explanation: https://sampwiki.blast.hk/wiki/Function:...erControllable
Reply
#3

Lol I was trying with that but my brain is just so tired.. I think I put it in the wrong place when I tried it.. Please be kind to my worn out stoned brain and show me some correct code that i can use

-1 for me being so brain dead
Reply
#4

This is the code I tried..

Код:
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
	new vehicle = GetPlayerVehicleID(playerid);
	if(enterexit == 1)
	{
		GetVehiclePos(vehicle, modx[playerid], mody[playerid], modz[playerid]);
		InModShop[playerid] = 1;
		TogglePlayerControllable(playerid, 0);
	}
	if(enterexit == 0)
	{
	    SetVehiclePos(vehicle, modx[playerid], mody[playerid], modz[playerid]);
	    InModShop[playerid] = 0;
	    TogglePlayerControllable(playerid, 1);
	}
	return 1;
}
Does not work.. I can still exit the vehicle in the mod shop.. What is wrong here?
Reply
#5

haha, I understand, had this alot lately :P
So, what this is not the exact code, but it's an example:
pawn Код:
if(IsPlayerInRangeOfPoint(playerid,5.0,mx,my,mz)){TogglePlayerControllable(playerid,0);}//mx, my and mz are the coords from inside the interior, where you have that mod menu
if(IsPlayerInRangeOfPoint(playerid,5.0,mxo,myo,mzo)){TogglePlayerControllable(playerid,1);}//mxo, myo and mzo are the coords where you first drive in
If you can get these coords yourself, and put this in a main timer or something, it will block/unblock the player at the right time.
I don't have any mapping program to get the coords for you at the moment, and I have to go to school in just a few minutes :P
I hope this will get you further

//EDIT: I just noticed you posted, sorry, didn't see that (remember to not double post ).
I will check your code, just a minute..

//EDIT2: I don't see any mistakes :\
The only thing I can think of is that you maybe didn't compile and restart your server.
Also, try to debug it, add a sendclientmessage with the text like "You entered the modshop" and the text ""You exited from the modshop".
Then try in game to see if it works.
I have to go now, and I hope someone else can help you solve the problem, if not, I will help you when I come home
Reply
#6

Definutely re-compiled, stopped and then restarted the server. (Exiting not gmx command)

The code I wrote is definutely not working or not written correctly.. Otherwise I don't know what it could be..

I shall debug the code and see if the messages are displaying at the correct times.. Will EDIT shortly with update..

EDIT: The sendclientmessage is showing up at the correct time when I enter..
Код:
TogglePlayerControllable(playerid, 0);
I don't think this code stops the player from exiting the vehicle whilst inside it.. Although when I have left the vehicle and I use the /freeze command on myself I am unable to use "F" or "ENTER" to go back inside the vehicle & I also cannot move until I /unfreeze myself.

When I get back into the vehicle.. I tried using the /freeze command on myself again to see if I could use "F" or "ENTER" to exit the vehicle and I could still leave the vehicle and then walk around even though I used the /freeze command on myself!

Any ideas?

EDIT 2: How can I make it so if
Код:
TogglePlayerControllable(playerid, 0);
Then the player cannot use

Код:
KEY_SECONDARY_ATTACK
I think this will solve the problem! But I can't think how to write it?

EDIT 3: FIXED IT! I was being a complete retard!! Look at this lol...

Код:
if (newkeys & KEY_SECONDARY_ATTACK)
	{
	    if(Papering[playerid] == 1)
	    {
	        TogglePlayerControllable(playerid, 0);
	        DisablePlayerCheckpoint(playerid);
	        Papering[playerid] = 0;
	        SendClientMessage(playerid,COLOR_RED,"You decided to stop the sidejob.");
	        RemoveDriverFromVehicle(playerid);
 		}
	    if(InAmbu[playerid] > 0)
	    {
	        new Float:X, Float:Y, Float:Z;
			GetVehiclePos(InAmbu[playerid], X, Y, Z);
			SetPlayerPos(playerid, X+4, Y, Z);
			SetPlayerInterior(playerid, 0);
			InAmbu[playerid] = 0;
		}
 		if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			RemoveDriverFromVehicle(playerid);
   	     	{
	            RemoveDriverFromVehicle(playerid);
	            if(PlayerInfo[playerid][pCarlic] == 0)
	            {
	                SetPlayerDrunkLevel (playerid, 0);
				}
	        }
		}
Some how whilst writing some code for a few job vehicles I had stupidly written some code so that if I pressed "F" or "ENTER" whilst my state was DRIVER it would remove me from the vehicle!

-1 yet again for me being so retarded and not spotting this (NOTE: I did not write that stupid code... Whoever knows this script well knows who done that lol! And trust me.. That isn't the only retarded thing I have found in this script! I've spent the last 3-4 days with a friend re-scripting the whole thing and it's shocking)
Reply
#7

(Bumping as my problem was not fixed!)

Hi guys please ignore everything above.. My problem is not yet solved but I know what I need to do in order to solve it I just need some help to write it please.

As you can see here is what happens when the player STATE is the DRIVER when I am pressing the "F" or "ENTER" key (SECONDARY ATTACK)
Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
		    RemoveDriverFromVehicle(playerid);
	        if(engine[GetPlayerVehicleID(playerid)] == 0)
	        {
	            RemoveDriverFromVehicle(playerid);
	            if(PlayerInfo[playerid][pCarlic] == 0)
	            {
	                SetPlayerDrunkLevel (playerid, 0);
				}
	        }
		}
I think it was made because the vehicle engine system that WAS in this script was simply using the TogglePlayerControllable, so when you got in the car you are unable to drive it BUT you can still exit the vehicle.

I want to make it so it checks
Код:
if(InModShop[playerid] == 1)
(IF the player IS IN the mod shop)
Then DO NOT ALLOW the person to use "F" or "ENTER" to exit the vehicle

and

Код:
if(InModShop[playerid] == 0)
(IF the player IS NOT in the mod shop)
Then ALLOW the person to use "F" or "ENTER" to exit the vehicle.

Any ideas on this would be great! I'm gonna go make a quick cup of coffee!

EDIT: RESOLVED!!

Код:
if (newkeys & KEY_SECONDARY_ATTACK)
	{
	    if(InModShop[playerid] == 1)
	    {
     		if (newkeys & KEY_SECONDARY_ATTACK) return 0;
  			TogglePlayerControllable(playerid, 0);
		}
	    if(InAmbu[playerid] > 0)
	    {
	        new Float:X, Float:Y, Float:Z;
			GetVehiclePos(InAmbu[playerid], X, Y, Z);
			SetPlayerPos(playerid, X+4, Y, Z);
			SetPlayerInterior(playerid, 0);
			InAmbu[playerid] = 0;
		}
 		if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			RemoveDriverFromVehicle(playerid);
  			if(engine[GetPlayerVehicleID(playerid)] == 0)
	        {
	            RemoveDriverFromVehicle(playerid);
	            if(PlayerInfo[playerid][pCarlic] == 0)
	            {
	                SetPlayerDrunkLevel (playerid, 0);
				}
	        }
		}
+1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)