Question with entrances -
Burning - 09.08.2014
Hi im creating entrances system and I would like to ask you how should I do that if there's a player in entrance enter or exit that he could enter/exit with [ENTER] key..That's my code:
Код:
forward Tunelis(tekstas[],Float:IejimasX,Float:IejimasY,Float:IejimasZ,Float:IsejimasX,Float:IsejimasY,Float:IsejimasZ,interjeras);
public Tunelis(tekstas[],Float:IejimasX,Float:IejimasY,Float:IejimasZ,Float:IsejimasX,Float:IsejimasY,Float:IsejimasZ,interjeras)
{
new msg[256];
format(msg,sizeof(msg),"[%s]\n[ENTER]",tekstas);
Create3DTextLabel(msg,0x008080FF,IejimasX,IejimasY,IejimasZ,10.0, 0, 0);
new msg1[256];
format(msg1,sizeof(msg1),"[%s IЉĖJIMAS]\n[ENTER]",tekstas);
Create3DTextLabel(msg1,0x008080FF,IsejimasX,IsejimasY,IsejimasZ,10.0, 0, 0);
print("[TUNELIAI] Uћkrauti");
return 1;
}
I know that I have to do something in OnPlayerKeyStateChange but I cant manage to work it out by myself
Re: Question with entrances -
kamiliuxliuxliux - 09.08.2014
pawn Код:
public OnPlayerKeyStateChange(playerid, newkays, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK) // if pressed ENTER
{
if(IsPlayerInRangeOfPoint(....)) // is player in range of IejimasX IejimasY IejimasZ....
{
SetPlayerPos(playerid, IsejimasX,IsejimasY,IsejimasZ);
}
else if(IsPlayerInRangeOfPoint(.....)) // is player in range of IsejimasXYZ
{
SetPlayerPos(playerid, IejimasX,IejimasY,IejimasZ);
}
}
return 1;
}
Re: Question with entrances -
Burning - 09.08.2014
error 017: undefined symbol "IejimasX"
Re: Question with entrances -
kamiliuxliuxliux - 09.08.2014
Because those parameters (IejimasXYZ, IsejimasXYZ) aren't global. They're only in Tunelis callback.
Re: Question with entrances -
Burning - 09.08.2014
So how should I do with current parameters or I have to create global parametres somehow?
Re: Question with entrances -
kamiliuxliuxliux - 09.08.2014
pawn Код:
new Float:IsejimasX = your_coords;
new Float:IsejimasY = your_coords;
new Float:IsejimasZ = your_coords;
new Float:IejimasX = your_coords;
new Float:IejimasY = your_coords;
new Float:IejimasZ = your_coords;
Re: Question with entrances -
Burning - 09.08.2014
if I will do like u recommended I will have to create so many variables with static coordinates, I need to fetch coordinates from Tunelis
Re: Question with entrances -
SKAzini - 09.08.2014
Here you go mate:
pawn Код:
new Entrances[MAX_ENTRANCES][entranceEnum], Entrances_Current=-1;
forward Tunelis(tekstas[],Float:IejimasX,Float:IejimasY,Float:IejimasZ,Float:IsejimasX,Float:IsejimasY,Float:IsejimasZ,interjeras);
public Tunelis(tekstas[],Float:IejimasX,Float:IejimasY,Float:IejimasZ,Float:IsejimasX,Float:IsejimasY,Float:IsejimasZ,interjeras)
{
new msg[256];
format(msg,sizeof(msg),"[%s]\n[ENTER]",tekstas);
Create3DTextLabel(msg,0x008080FF,IejimasX,IejimasY,IejimasZ,10.0, 0, 0);
new msg1[256];
format(msg1,sizeof(msg1),"[%s IЉĖJIMAS]\n[ENTER]",tekstas);
Create3DTextLabel(msg1,0x008080FF,IsejimasX,IsejimasY,IsejimasZ,10.0, 0, 0);
Entrances[Entrances_Current+1][Iejimas][0] = IejimasX;
Entrances[Entrances_Current+1][Iejimas][1] = IejimasY;
Entrances[Entrances_Current+1][Iejimas][2] = IejimasZ;
Entrances[Entrances_Current+1][Iejimas][0] = IsejimasX;
Entrances[Entrances_Current+1][Iejimas][1] = IsejimasY;
Entrances[Entrances_Current+1][Iejimas][2] = IsejimasZ;
Entrances[Entrances_Current+1][interjeras] = interjeras;
print("[TUNELIAI] Uћkrauti");
return 1;
}
public OnPlayerKeyStateChange(playerid, newkays, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK)
{
for(new i; i < MAX_ENTRANCES; i++) //or for(new i; i < Entrances_Current+1; i++)
{
if(IsPlayerInRangeOfPoint(Entrances[i][Iejimas][0], Entrances[i][Iejimas][1], Entrances[i][Iejimas][2])
{
SetPlayerPos(playerid, Entrances[i][Isejimas][0], Entrances[i][Isejimas][1], Entrances[i][Isejimas][2]);
SetPlayerInterior(playerid, interjeras);
break;
}
else if(IsPlayerInRangeOfPoint(Entrances[i][Isejimas][0], Entrances[i][Isejimas][1], Entrances[i][Isejimas][2])
{
SetPlayerPos(playerid, Entrances[i][Iejimas][0], Entrances[i][Iejimas][1], Entrances[i][Iejimas][2]);
SetPlayerInterior(playerid, 0);
break;
}
}
}
return 1;
}