SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 17/10/2019, 09:40 AM   #1
KensPTV
Big Clucker
 
KensPTV's Avatar
 
Join Date: Oct 2019
Location: Vietnamese
Posts: 72
Reputation: 0
Default sync issues [/enter] and [/exit]

- Hi guys, I need help with an sync issues [CMD: enter] and [CMD: exit], when in the game instead of pressing [/enter], [/exit] to enter and exit a door. Now I need everyone to help sync it by pressing "N" on the keyboard to get in and out.
- Video example:
https://www.youtube.com/watch?v=-OSK...ature=youtu.be
__________________
Kens.P TV @ Youtuber
Scripting @ Samp
Adminstrator @ Designer @ [KG:RP]
KensPTV is offline   Reply With Quote
Old 17/10/2019, 12:30 PM   #2
MustafaKemalAtaturk
Little Clucker
 
MustafaKemalAtaturk's Avatar
 
Join Date: Mar 2015
Location: Turkey
Posts: 16
Reputation: 0
Default Re: sync issues [/enter] and [/exit]

You can use this for your KeyState method;
Code:
if((newkeys & KEY_NO) && !(oldkeys & NO))
MustafaKemalAtaturk is offline   Reply With Quote
Old 17/10/2019, 04:17 PM   #3
KensPTV
Big Clucker
 
KensPTV's Avatar
 
Join Date: Oct 2019
Location: Vietnamese
Posts: 72
Reputation: 0
Default Re: sync issues [/enter] and [/exit]

- Hey bro, I could only sync [CMD: enter] and [CMD: exit] I could not do it. I need your help, buddy.

Code:
- Code:
    new NO;
    if((newkeys & KEY_NO) && !(oldkeys & NO))
	{
		return cmd_enter(playerid, "");
                return cmd_exit(playerid, "");
	}
Code:
- This is Error:
./includes/KG EDIT.pwn(107328) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Warning
__________________
Kens.P TV @ Youtuber
Scripting @ Samp
Adminstrator @ Designer @ [KG:RP]
KensPTV is offline   Reply With Quote
Old 17/10/2019, 04:48 PM   #4
KensPTV
Big Clucker
 
KensPTV's Avatar
 
Join Date: Oct 2019
Location: Vietnamese
Posts: 72
Reputation: 0
Default Re: sync issues [/enter] and [/exit]

- Help me, i need (
- I almost complete it. Everybody can help me, please
__________________
Kens.P TV @ Youtuber
Scripting @ Samp
Adminstrator @ Designer @ [KG:RP]
KensPTV is offline   Reply With Quote
Old 17/10/2019, 05:17 PM   #5
IzadorO
Big Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 160
Reputation: 11
Default Re: sync issues [/enter] and [/exit]

You are saying cmd_exit doesn't work? That's because you are doing "return cmd_enter(...)" before return cmd_exit, which means cmd_enter will always be called and cmd_exit will not. What return does is end the callback and return the specified value or a result from a function if used that way, so that is why it is not reaching the exit part of your script.

What you need to do is run a check to determine whether the player is already inside an interior, or not. Like this...

if (GetPlayerInterior(playerid))
cmd_exit(playerid, "");
else
cmd_enter(playerid, "");

Something along those lines...
IzadorO is offline   Reply With Quote
Old 17/10/2019, 05:50 PM   #6
KensPTV
Big Clucker
 
KensPTV's Avatar
 
Join Date: Oct 2019
Location: Vietnamese
Posts: 72
Reputation: 0
Default Re: sync issues [/enter] and [/exit]

- Hey bro, I need help. I did it on your own but there were a few issues here. Below is the code snippet and the error code I encountered! Can you look at my code and edit it into new code? I need bro @IzadorO help me this issues.

Quote:
- This is Error:
./includes/KG EDIT.pwn(107328 ) : warning 225: unreachable code
./includes/KG EDIT.pwn(107328 ) : error 029: invalid expression, assumed zero
./includes/KG EDIT.pwn(107328 -- 107329) : warning 215: expression has no effect
./includes/KG EDIT.pwn(107329) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Quote:
- This is my Code:
new NO;
if((newkeys & KEY_NO) && !(oldkeys & NO))
{
return cmd_enter(playerid, "");
else
if(GetPlayerInterior(playerid))
{
return cmd_exit(playerid, "");
}
}
__________________
Kens.P TV @ Youtuber
Scripting @ Samp
Adminstrator @ Designer @ [KG:RP]
KensPTV is offline   Reply With Quote
Old 17/10/2019, 05:52 PM   #7
IzadorO
Big Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 160
Reputation: 11
Default Re: sync issues [/enter] and [/exit]

I see what you done wrong, here is the fix.

if (newkeys & KEY_NO)
{
if (GetPlayerInterior(playerid))
cmd_exit(playerid, "");
else
cmd_enter(playerid, "");
}

You placed else under return cmd_enter and above the if (GetPlayerInterior(playerid)) check, which means that the statement was invalid as there was no prior check which it was linked to. You also shouldn't do returns unless necessary, and it's not necessary here.

I also saw that you had oldkeys & NO after you created a new variable named NO. This would never work as you didn't define a value for that variable, and it isn't necessary either as oldkeys does the required check, so instead you would put oldkeys & KEY_NO.

https://wiki.sa-mp.com/wiki/Keys
IzadorO is offline   Reply With Quote
Old 17/10/2019, 08:37 PM   #8
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,442
Reputation: 1620
Default Re: sync issues [/enter] and [/exit]

Code:
You shouldn't do returns unless necessary
And why not? If there's plenty of code within the callback and you never use returns because you are like. "Ah. Not using return. No function is asking for a result".
Hello statements being checked and eventual codes being executed while the player already was sent to somewhere else and it might be running irrelative code. That is unecessary.
His script has atleast 107328 lines. So quite a chance some of his runtime is wasted if there is indeed code within the callback if the player was teleported.
All I'm saying is, when saying things like that you should add some explaination or define what 'necessary' is. Otherwise there is a huge chance that OP would learn bad habits
Kwarde is offline   Reply With Quote
Old 17/10/2019, 09:25 PM   #9
IzadorO
Big Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 160
Reputation: 11
Default Re: sync issues [/enter] and [/exit]

Very good point, you are correct. I failed to explain that part with the correct context.
IzadorO is offline   Reply With Quote
Old 18/10/2019, 06:30 AM   #10
KensPTV
Big Clucker
 
KensPTV's Avatar
 
Join Date: Oct 2019
Location: Vietnamese
Posts: 72
Reputation: 0
Default Re: sync issues [/enter] and [/exit]

- Bro, it can only be accessed by a few doors, / enter but / exit only a few doors can be used.
- Why ?
__________________
Kens.P TV @ Youtuber
Scripting @ Samp
Adminstrator @ Designer @ [KG:RP]
KensPTV 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
[Tutorial] Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] zDevon Tutorials 19 18/07/2015 10:32 PM
Help /enter /exit Taykiro Scripting Help 2 15/04/2013 05:49 AM
Bug: no Sync when a player enter and exits of an interior bruno_orlandi Help Archive 0 13/09/2009 02:03 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 05:26 AM.


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