made some changes to now open the gate by pressing the "M" button to not cause errors and lags
Script
function onServerStart()
{
gate <- array( GetMaxPlayers(), null );
gateStatus = true;
gate = CreateObject( 310, 1, -276.618, -495.992, 10.2778, 255 );
}
function onScriptLoad()
{
gateStatus <- array( GetMaxPlayers(), null );
M <- BindKey(true, 0x4D,0,0);
}
function onKeyDown( player, bind )
{
if( bind == M )
{
if ( InPoly( player.Pos.x, player.Pos.y, -276.475, -501.47,-268.81, -501.221,-268.959, -489.333,-276.775, -490.022 ) )
{
Gate1( player );
}
}
}
Functions
function Gate1( player )
{
if ( InPoly( player.Pos.x, player.Pos.y, -276.475, -501.47,-268.81, -501.221,-268.959, -489.333,-276.775, -490.022 ) && gateStatus == true )
{
gate.MoveTo(Vector( -268.576, -495.99, 10.2778), 2800 );
gateStatus = false;
}
else
{
if ( gateStatus == false )
{
gate.MoveTo(Vector(-276.618, -495.992, 10.2778), 2800 );
gateStatus = true;
}
}
}
Pictures
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FPVK7piw.jpg&hash=b0aeb485a7253225db5ceb4d313471f708a313b6)
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FVTzVm5y.jpg&hash=717badd632698fa9cb17e258d0f40be06e141fb1)
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2F2tYptLq.jpg&hash=e3304781b507ab2683b5f4d0cf4e99fc132fd6e2)
This will lag the sh!t out of a full server :D Imagine 50 players moving which can almost cause 10 onPlayerMove() calls per second for each player. Therefore 50 * ~10 = ~500 Gate1() calls per second. I know it's not much but think of it when you start adding more of those gates and other things like that where you depend on the onPlayerMove() function. There wont be any room left for the rest of the code.
Suggestion:
Create a general action key-bind and when the action key-bind is pressed then test in which area the player is currently located and trigger the effect withing that area (if any). This allows for multiple automatic gates and other things on the server without lagging the sh!it out of it.
Two inpoly calls when you clearly only need 1 makes it even worse.
Do not use this, or watch your server die.
I have already a automatic gate in my server but guess m not using onPlayerMove
Quote from: Thijn on Dec 14, 2014, 11:04 AMTwo inpoly calls when you clearly only need 1 makes it even worse.
Do not use this, or watch your server die.
UpdateInpoly and onplayermove removed!
Nice friend.
Thanks for sharing
getting error here
if( bind == M )
Quote from: Squirrel Master on Feb 27, 2015, 03:26 PMgetting error here
if( bind == M )
Man this is the third time you do this sh!t. Can you at least tell us the error.
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi61.tinypic.com%2Favl8xj.png&hash=6db01192c6f57eaaf70570014a9cebc74686246b)
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi59.tinypic.com%2Ffedngm.png&hash=c54af440aa607ab61b6a0c2a59a4053c1d838a74)
Check it now
Similar problem change bind == M
To key == M
Then see what happens
And dont use pawnox that tool is for other language better use Notepad++
Your argument is named differently. Since this isn't the original code then I'm afraid it's not the author's fault.
oh yeah
Thanks
Quote from: Squirrel Master on Feb 27, 2015, 07:08 PMoh yeah
Thanks
I wonder from whereever you are a squirrel master, let alone a copying master. You dont know what bind means and what you are supposed to change it to by looking at how the code works. I suggest you, try making one script completely of your own and when it is totally completed, then show us what doesnt work, but not before completing it. We'll be glad to help, you'll be glad to learn.
well i am having this problem!!
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FQ1iUiBn.jpg&hash=b62589952f8da990fe02e671c4119ca8532b327f)
Quote from: DeCeNt_BoY on May 12, 2015, 11:38 AMwell i am having this problem!!
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FQ1iUiBn.jpg&hash=b62589952f8da990fe02e671c4119ca8532b327f)
onServerStart is executed before onScriptLoad so that variable would not be initialized. I suggest you to take "gateStatus <- ..." to onServerStart and above the line that error is occurring.
P.S. Nice editor! If its like Atom, pressing CTRL + [Arrow up] will move a line.
Quote from: NE.CrystalBlue on May 12, 2015, 12:30 PMonServerStart is executed before onScriptLoad so that variable would not be initialized. I suggest you to take "gateStatus <- ..." to onServerStart and above the line that error is occurring.
well i did that, again same error occurs.. just number of line changed.. :/
Quote from: NE.CrystalBlue on May 12, 2015, 12:30 PMP.S. Nice editor! If its like Atom, pressing CTRL + [Arrow up] will move a line
thankx!! and the key CTRL + SHIFT + [ARROW UP] Worked for me!! ;)
@DeCeNt_BoY This is off-topic but press
Control+Shift+P inside Sublime Text and then type
SSD (case insensitive) and then hit enter. Trust me, it'll be an improvement on syntax highlighting ;)
Quote from: NE.CrystalBlue on May 12, 2015, 12:30 PMP.S. Nice editor! If its like Atom, pressing CTRL + [Arrow up] will move a line.
Same thing works in Notepad++ too ;)
Quote from: DeCeNt_BoY on May 12, 2015, 01:23 PMQuote from: NE.CrystalBlue on May 12, 2015, 12:30 PMonServerStart is executed before onScriptLoad so that variable would not be initialized. I suggest you to take "gateStatus <- ..." to onServerStart and above the line that error is occurring.
well i did that, again same error occurs.. just number of line changed.. :/
Well... Did you put that dude above* that line?
yeah!!!
Simply put everthing in onScriptLoad()
function onScriptLoad()
{
gateStatus <- array( GetMaxPlayers(), null );
M <- BindKey(true, 0x4D,0,0);
gate <- array( GetMaxPlayers(), null );
gateStatus = true;
gate = CreateObject( 310, 1, -276.618, -495.992, 10.2778, 255 );
}
in console bind not find how to do fix it