need help with automatic gates! - 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: need help with automatic gates! (
/showthread.php?tid=93262)
need help with automatic gates! -
BMGP - 24.08.2009
Hi!
i just made automativ gates but then i wanted taht only one Team can use it.
(if(gTeam[playerid] == TEAM_NWC))
i have to put it in the gamemode. First there were warnings:
Код:
Warning) local variable "x" shadows a variable at a preceding level
same with "y" and "z".
So i wrote:
Код:
forward PlayerToPoint(Float:radi, playerid, Float:x111, Float:y111, Float:z111);
public PlayerToPoint(Float:radi, playerid, Float:x111, Float:y111, Float:z111)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx111, Float:oldposy111, Float:oldposz111;
new Float:tempposx111, Float:tempposy111, Float:tempposz111;
GetPlayerPos(playerid, oldposx111, oldposy111, oldposz111);
tempposx111 = (oldposx111 -x)
tempposy111 = (oldposy111 -y);
tempposz111 = (oldposz111 -z);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx111 < radi) && (tempposx111 > -radi)) && ((tempposy111 < radi) && (tempposy111 > -radi)) && ((tempposz111 < radi) && (tempposz111 > -radi)))
{
return 1;
}
}
return 0;
}
when i started the game i ran to the doors but they didnt open!
and where i have to put the (if(gTeam[playerid] == TEAM_NWC))??
help!
Re: need help with automatic gates! -
Energyzer - 24.08.2009
I think, all is wrong, for Automatic Gates i use this code;
1. Put this in your GameMode/filterscript.
pawn Код:
new gate;
new OpenGate[MAX_PLAYERS];
2. Put this in your GameModeInit or OnFilterScripts.
pawn Код:
gate = CreateObject(ID,X,Y,Z,RX, RY, RZ);
SetTimer("TimerGate", 500, true);
3. Put this in anywhere.
pawn Код:
forward TimerGate();
public TimerGate()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected( i ))
{
if(PlayerToPoint(15.0, i,COORDINATES) && OpenGate[i] == 0)
{
OpenGate[i] = 1;
MoveObject(gate, COORDINATES, SPEED);
}
else if(!PlayerToPoint(15.0, i,1COORDINATES) && OpenGate[i] == 1)
{
OpenGate[i] = 0;
MoveObject(gated,COORDINATES, SPEED);
}
}
}
}
4. Replace the fuction playertopoint for this.
pawn Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
Good Luck!
Re: need help with automatic gates! -
BMGP - 24.08.2009
good german scripter posted the script what i use in another forum xDDDD
but i try your one!
EDIT:
SAME ERROR(local variable "x" ....(first post..)
same with y and z