SA-MP Forums Archive
Damn gate wont open... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Damn gate wont open... (/showthread.php?tid=103814)

Pages: 1 2


Damn gate wont open... - Danikov - 21.10.2009

I Made a gate but it wont open,here are the lines...

Код:
PlayerToPoint(Float:radius, playerid, Float:X, Float:Y, Float:Z)
{
  new Float:oldpos[3], Float:temppos[3];
  GetPlayerPos(playerid, oldpos[0], oldpos[1], oldpos[2]);
  temppos[0] = (oldpos[0] -X);
  temppos[1] = (oldpos[1] -Y);
  temppos[2] = (oldpos[2] -Z);
  if(((temppos[0] < radius) && (temppos[0] > -radius)) && ((temppos[1] < radius) && (temppos[1] > -radius)) && ((temppos[2] < radius) && (temppos[2] > -radius)))
  {
    return true;
  }
  return false;
}

public CheckGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(PlayerToPoint(10.0, i, 213.880005, 1875.686768, 10.506058) && OpenGate[i] == 0)
    {
      MoveObject(c_gate, 213.882446, 1875.694214, 14.031004,5);
      OpenGate[i] = 1;
    }
    else if(!PlayerToPoint(10.0,i, 213.880005, 1875.686768, 10.506058) && OpenGate[i] == 1)
    {
      OpenGate[i] = 0;
    }
  }
}
And this:

Код:
new c_gate;
new OpenGate[MAX_PLAYERS];
forward CheckGate();
And this:

Код:
c_gate=CreateObject(11327, 213.882446, 1875.694214, 14.031004, 0.000000, 0.000000, 270.000001124); //
So whats wrong,why it wont open,im using samp 0.3


Re: Damn gate wont open... - yugokoral - 21.10.2009

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint


Re: Damn gate wont open... - Danikov - 21.10.2009

Ok ill see what i can do


Re: Damn gate wont open... - yugokoral - 21.10.2009

Did you make a timer for CheckGate?


Re: Damn gate wont open... - Danikov - 21.10.2009

Where should i put this?OnPlayerCommandText?and yes i made a timer


Re: Damn gate wont open... - yugokoral - 21.10.2009

Try without IsPlayerConnected. OnPlayerCommandText is a public!


Re: Damn gate wont open... - Danikov - 21.10.2009

Nope,Nothing,Dude please help meh D:


Re: Damn gate wont open... - yugokoral - 21.10.2009

LOL!!! youre moving your gate from one to the same position, so you cant see the result xD. Fix this, select your move position!


Re: Damn gate wont open... - Danikov - 21.10.2009

xD LOL


Re: Damn gate wont open... - yugokoral - 21.10.2009

You can try this too, more simple :
pawn Код:
#include <a_samp>

new c_gate;

public OnFilterScriptInit()
{
  c_gate = CreateObject(11327, 213.882446, 1875.694214, 14.031004, 0.000000, 0.000000, 270.000001124); //the created object
  SetTimer("CheckGate", 100, 1);
    return 1;
}

forward CheckGate();
public CheckGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerInRangeOfPoint(i, 10.0, 213.880005, 1875.686768, 10.506058))
    {
      MoveObject(c_gate, 213.882446, 1875.694214, 14.031004,5);//move objest from position, where you created to x, y, z (you must input)
            //you have the same x,y,z positions like created
      return 1;
    }
   
  }
  MoveObject(c_gate, 213.882446, 1875.694214, 14.031004,5);
  return 1;
}



Re: Damn gate wont open... - Danikov - 21.10.2009

Errrr Dude,Why the gate wont come back up?
Код:
PlayerToPoint(Float:radius, playerid, Float:X, Float:Y, Float:Z)
{
  new Float:oldpos[3], Float:temppos[3];
  GetPlayerPos(playerid, oldpos[0], oldpos[1], oldpos[2]);
  temppos[0] = (oldpos[0] -X);
  temppos[1] = (oldpos[1] -Y);
  temppos[2] = (oldpos[2] -Z);
  if(((temppos[0] < radius) && (temppos[0] > -radius)) && ((temppos[1] < radius) && (temppos[1] > -radius)) && ((temppos[2] < radius) && (temppos[2] > -radius)))
  {
    return true;
  }
  return false;
}

public CheckGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(PlayerToPoint(10.0, i, 213.880005, 1875.686768, 10.506058) && OpenGate[i] == 0)
    {
      MoveObject(c_gate, 213.880005, 1875.686768, 10.506058,1);
      OpenGate[i] = 1;
    }
    else if(!PlayerToPoint(10.0,i, 213.882446, 1875.694214, 14.031004) && OpenGate[i] == 1)
    {
      OpenGate[i] = 0;
    }
  }
}



Re: Damn gate wont open... - yugokoral - 21.10.2009

PlayerToPoint is old created function! Use my before posted script! Theres already created new function made by Kye already in 0.3: IsPlayerInRangeOfPoint! BTW, old code will work too but maybe you made something wrong. Try my code!


Re: Damn gate wont open... - Danikov - 21.10.2009

The forward CheckGate() ; and public CheckGate() should be under new c_gate;?


Re: Damn gate wont open... - yugokoral - 21.10.2009

I think yes.


Re: Damn gate wont open... - Danikov - 21.10.2009

oh no wait i got that everything is okay i only get one warning which is:
Код:
D:\Documents and Settings\victor\Desktop\SAMP Server\pawno\A51.pwn(303) : warning 203: symbol is never used: "c_gate"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.



Re: Damn gate wont open... - yugokoral - 21.10.2009

You using your or my script? And show me all your code, i will see whats wrong.


Re: Damn gate wont open... - Danikov - 21.10.2009

I Use yours


Re: Damn gate wont open... - yugokoral - 21.10.2009

At me compiles without errors!


Re: Damn gate wont open... - Danikov - 21.10.2009

I Did same as you!

Here is the first lines...

Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
new BlackProject;
new c_gate;


#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
  c_gate = CreateObject(11327, 213.882446, 1875.694214, 14.031004, 0.000000, 0.000000, 270.000001124); //the created object
  SetTimer("CheckGate", 100, 1);
return 1;
}

forward CheckGate();
public CheckGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerInRangeOfPoint(i, 10.0, 213.880005, 1875.686768, 10.506058))
    {
      MoveObject(c_gate, 213.882446, 1875.694214, 14.031004,5);//move objest from position, where you created to x, y, z (you must input)
//you have the same x,y,z positions like created
      return 1;
    }

  }
  MoveObject(c_gate, 213.882446, 1875.694214, 14.031004,5);
  return 1;
}



Re: Damn gate wont open... - yugokoral - 21.10.2009

I dont know, sory, i compiling without errors.