Damn gate wont open...
#1

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
Reply
#2

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Reply
#3

Ok ill see what i can do
Reply
#4

Did you make a timer for CheckGate?
Reply
#5

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

Try without IsPlayerConnected. OnPlayerCommandText is a public!
Reply
#7

Nope,Nothing,Dude please help meh D:
Reply
#8

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

xD LOL
Reply
#10

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;
}
Reply
#11

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;
    }
  }
}
Reply
#12

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!
Reply
#13

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

I think yes.
Reply
#15

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.
Reply
#16

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

I Use yours
Reply
#18

At me compiles without errors!
Reply
#19

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;
}
Reply
#20

I dont know, sory, i compiling without errors.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)