SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 05/02/2015, 04:12 AM   #1
Lucky™
Huge Clucker
 
Lucky™'s Avatar
 
Join Date: Jul 2012
Location: Tomorrowland
Posts: 252
Reputation: 63
Default Pressing a key to enter/exit building

I want to make it like, when a user press 'Y' on keyboard he can enter/exit building. This is what I have so far. When I press 'Y'. It quickly enters and exits the building. Do I have to do anything with return?

pawn Code:
if(newkeys == 65536)
    {
          cmd_enter(playerid);
          return 0;
    }
    else {
          cmd_exit(playerid);
    }
Lucky™ is offline   Reply With Quote
Old 05/02/2015, 04:44 AM   #2
ATGOggy
Gangsta
 
Join Date: Sep 2014
Location: Ls-rcr
Posts: 850
Reputation: 52
Default Re: Pressing a key to enter/exit building

pawn Code:
if(newkeys == 65536)
{
    if(GetPlayerInterior(playerid)==0 && GetPlayerVirtualWorld(playerid)==0)
    {
          cmd_enter(playerid);
    }
    else
    {
          cmd_exit(playerid);
    }
}
__________________
******: "I've said this before. People think that MySQL is some simple plug-and-play magic bullet that you can use to just make your mode instantly better. They don't realise that the "L" in "SQL" means "language". So instead of programming PAWN, and using a bit of this mystery thing, you are now programming in two languages at once. If you spend months learning PAWN, you should spend the same time learning SQL, if not more - it is probably the more complex of the two languages, and not something that just gets bolted on to the side."


I give and want only fair reps. I hate this: "hey bro, I rep you, rep me plz

Click below if you wanna be amazed:
http://Paid2Refer.com/ref.php?refId=291262
ATGOggy is offline   Reply With Quote
Old 05/02/2015, 07:08 AM   #3
Lucky™
Huge Clucker
 
Lucky™'s Avatar
 
Join Date: Jul 2012
Location: Tomorrowland
Posts: 252
Reputation: 63
Default Re: Pressing a key to enter/exit building

Quote:
Originally Posted by ATGOggy View Post
pawn Code:
if(newkeys == 65536)
{
    if(GetPlayerInterior(playerid)==0 && GetPlayerVirtualWorld(playerid)==0)
    {
          cmd_enter(playerid);
    }
    else
    {
          cmd_exit(playerid);
    }
}
Server getting crashed, not sure why.
You can enter by pressing Y and it crashes the server as soon as you entered.

Server log says nothing
Lucky™ is offline   Reply With Quote
Old 05/02/2015, 07:40 AM   #4
ahmedkoki
Big Clucker
 
Join Date: Aug 2012
Posts: 96
Reputation: 5
Default Re: Pressing a key to enter/exit building

Try this
pawn Code:
if(newkeys == KEY_YES)
{
    if(GetPlayerInterior(playerid)==0 && GetPlayerVirtualWorld(playerid)==0)
    {
          cmd_enter(playerid);
    }
    else
    {
          cmd_exit(playerid);
    }
}
__________________
ahmedkoki is offline   Reply With Quote
Old 05/02/2015, 07:51 AM   #5
Lucky™
Huge Clucker
 
Lucky™'s Avatar
 
Join Date: Jul 2012
Location: Tomorrowland
Posts: 252
Reputation: 63
Default Re: Pressing a key to enter/exit building

Quote:
Originally Posted by ahmedkoki View Post
Try this
pawn Code:
if(newkeys == KEY_YES)
{
    if(GetPlayerInterior(playerid)==0 && GetPlayerVirtualWorld(playerid)==0)
    {
          cmd_enter(playerid);
    }
    else
    {
          cmd_exit(playerid);
    }
}
No luck. still crashing.

I'm getting this warning in line 5035, 5039 while compiling

pawn Code:
warning 202: number of arguments does not match definition

line 5035 = cmd_enter
line 5039 = cmd_exit
Lucky™ is offline   Reply With Quote
Old 05/02/2015, 08:04 AM   #6
ahmedkoki
Big Clucker
 
Join Date: Aug 2012
Posts: 96
Reputation: 5
Default Re: Pressing a key to enter/exit building

Try this
pawn Code:
if(newkeys == KEY_YES)
{
    if(GetPlayerInterior(playerid)==0 && GetPlayerVirtualWorld(playerid)==0)
    {
          cmd_enter(playerid, params);
          return 1;
    }
    else
    {
          cmd_exit(playerid, params);
          return 1;
    }
}
__________________
ahmedkoki is offline   Reply With Quote
Old 05/02/2015, 08:23 AM   #7
ZombieNest
Huge Clucker
 
ZombieNest's Avatar
 
Join Date: Oct 2013
Location: Neverland
Posts: 260
Reputation: 40
Cool Re: Pressing a key to enter/exit building

EDIT:
Add this at top of your script after #include <a_samp>
Code:
 #include <zcmd>
Try this one!
Also add this on top of your script!
Code:
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
You should have command enter and exit registered in the server using ZCMD, Else maybe crash?
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_YES))
	{
	    new params[128];
    	if(GetPlayerInterior(playerid) == 0)
    	{
     		return cmd_enter(playerid, params);
    	}
    	else if(GetPlayerInterior(playerid) != 0)
    	{
          	return cmd_exit(playerid, params);
		}
	}
	return 1;
}
Also use Crash Detect to check the logs of crash!
Use crash detect and tell me the logs please -.-
You must use ZCMD its a good command processor!
-
http://www.solidfiles.com/d/879d1213...c8cf9/zcmd.inc
Example made by me:
Code:
CMD:enter(playerid, params[])
{
	SendClientMessage(playerid, -1, "Command Tested & Works!");
	return 1;
}

CMD:exit(playerid, params[])
{
	SendClientMessage(playerid, -1, "Command Tested & Works!");
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_YES))
	{
	    new params[128];
    	if(GetPlayerInterior(playerid) == 0)
    	{
     		return cmd_enter(playerid, params);
    	}
    	else if(GetPlayerInterior(playerid) != 0)
    	{
          	return cmd_exit(playerid, params);
		}
	}
	return 1;
}
EDIT: Oh yeah look up!
Tell me if it works or not I didnt tested but I know it will all work fine!
__________________
•?((¯°·._.• uwotmate? •._.·°¯))؟•

Quote:
Originally Posted by SA-MP Forums Bot View Post
So--
Quote:
Originally Posted by ZombieNest View Post
Pro.
Quote:
Originally Posted by :o View Post
Quote:
Originally Posted by vBulletin Error View Post
vBulletin Message
No Thread specified. If you followed a valid link, please notify the administrator.
Is that a excuse?
Yeah, maybe

Last edited by ZombieNest; 05/02/2015 at 08:36 AM. Reason: wawa
ZombieNest is offline   Reply With Quote
Old 05/02/2015, 11:26 AM   #8
Lucky™
Huge Clucker
 
Lucky™'s Avatar
 
Join Date: Jul 2012
Location: Tomorrowland
Posts: 252
Reputation: 63
Default Re: Pressing a key to enter/exit building

Quote:
Originally Posted by ZombieNest View Post
EDIT:
Add this at top of your script after #include <a_samp>
Code:
 #include <zcmd>
Try this one!
Also add this on top of your script!
Code:
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
You should have command enter and exit registered in the server using ZCMD, Else maybe crash?
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_YES))
	{
	    new params[128];
    	if(GetPlayerInterior(playerid) == 0)
    	{
     		return cmd_enter(playerid, params);
    	}
    	else if(GetPlayerInterior(playerid) != 0)
    	{
          	return cmd_exit(playerid, params);
		}
	}
	return 1;
}
Also use Crash Detect to check the logs of crash!
Use crash detect and tell me the logs please -.-
You must use ZCMD its a good command processor!
-
http://www.solidfiles.com/d/879d1213...c8cf9/zcmd.inc
Example made by me:
Code:
CMD:enter(playerid, params[])
{
	SendClientMessage(playerid, -1, "Command Tested & Works!");
	return 1;
}

CMD:exit(playerid, params[])
{
	SendClientMessage(playerid, -1, "Command Tested & Works!");
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_YES))
	{
	    new params[128];
    	if(GetPlayerInterior(playerid) == 0)
    	{
     		return cmd_enter(playerid, params);
    	}
    	else if(GetPlayerInterior(playerid) != 0)
    	{
          	return cmd_exit(playerid, params);
		}
	}
	return 1;
}
EDIT: Oh yeah look up!
Tell me if it works or not I didnt tested but I know it will all work fine!
Works fine Thank you and repped.

and yeah I'm using zcmd
Lucky™ is offline   Reply With Quote
Old 05/02/2015, 01:07 PM   #9
ZombieNest
Huge Clucker
 
ZombieNest's Avatar
 
Join Date: Oct 2013
Location: Neverland
Posts: 260
Reputation: 40
Default Re: Pressing a key to enter/exit building

No problem, I hoped my scripting is fine.
__________________
•?((¯°·._.• uwotmate? •._.·°¯))؟•

Quote:
Originally Posted by SA-MP Forums Bot View Post
So--
Quote:
Originally Posted by ZombieNest View Post
Pro.
Quote:
Originally Posted by :o View Post
Quote:
Originally Posted by vBulletin Error View Post
vBulletin Message
No Thread specified. If you followed a valid link, please notify the administrator.
Is that a excuse?
Yeah, maybe
ZombieNest 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
[Tutorial] Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] zDevon Tutorials 19 18/07/2015 09:32 PM
[FAST-HELP] PRESSING ENTER TO BYPASS LOGIN DIALOG [Cali]ChrOnic_T Server Support 5 02/07/2014 09:18 PM
how to enter the building or door by pressing the enter key kurniarocki Scripting Help 6 08/04/2014 05:43 AM
key to enter and exit building [Headless] Scripting Help 9 26/11/2011 09:03 AM
how to create an /exit and /enter command to enter an costum interior? sandisk125 Help Archive 5 18/08/2009 01:07 PM


All times are GMT. The time now is 11:28 AM.


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