[Duda] Entrar y salir del agua -
sergios - 02.02.2013
Hola, una pregunta como puedo detectar cuando alguien entra y sale del agua?
Respuesta: [Duda] Entrar y salir del agua -
adri1 - 02.02.2013
Se puede detectar con animaciуn, pero no lo detectarб si esta en vehнculo
pawn Код:
stock IsPlayerInWater(playerid)
{
new animlib[10], animname[10];
GetAnimationName(GetPlayerAnimationIndex(playerid), animlib, sizeof(animlib), animname, sizeof(animname));
return (!strcmp(animlib, "SWIM")) ? 1 : 0;
}
O tambiйn por coords. (Mбs eficaz, debido a que si por ejemplo cae al agua (mar) tambiйn lo detecta, el de la animaciуn no.
pawn Код:
stock IsPlayerInWater(playerid)
{
new Float:FXF_wpos[3];
GetPlayerPos(playerid,FXF_wpos[0],FXF_wpos[1],FXF_wpos[2]);
if((FXF_wpos[2] > 0.00) || IsPlayerInZone(playerid,1808.2019,1424.5392,-2230.5024,-2347.7979)) { return 0; }
else if((FXF_wpos[2] < 0.00) && (FXF_wpos[2] > -1.00)) { return 1; }
else if(FXF_wpos[2] < -1.00) { return 2; }
return 0;
}
Usos:
pawn Код:
if (strcmp(cmdtext, "/test", true)==0)
{
if(IsPlayerInWater(playerid))
{
SendClientMessage(playerid,-1,"Estas en el agua");
}
else
{
SendClientMessage(playerid,-1,"No estas en el agua");
}
return 1;
}
Crйditos de la funciуn: No sй la encontre por ahн
Respuesta: [Duda] Entrar y salir del agua -
sergios - 02.02.2013
El stock compila bien, pero cuando pongo ese comando para verificar que funcione me marca un error pawno:
pawn Код:
function "IsPlayerInZone" is not implemented
Respuesta: [Duda] Entrar y salir del agua -
Zume - 02.02.2013
Acб te dejo algo que quizб te sirva, estб en el gamemode que puse hace poco
pawn Код:
forward EstaEnAlberca(playerid);
public EstaEnAlberca(playerid)
{
new Float:x,Float:y,Float:pz;
GetPlayerPos(playerid,x,y,pz);
if (
(IsPlayerInArea(playerid, 2032.1371, 1841.2656, 1703.1653, 1467.1099) && pz <= 9.0484)
|| (IsPlayerInArea(playerid, 2109.0725, 2065.8232, 1962.5355, 10.8547) && pz <= 10.0792)
|| (IsPlayerInArea(playerid, -492.5810, -1424.7122, 2836.8284, 2001.8235) && pz <= 41.06)
|| (IsPlayerInArea(playerid, -2675.1492, -2762.1792, -413.3973, -514.3894) && pz <= 4.24)
|| (IsPlayerInArea(playerid, -453.9256, -825.7167, -1869.9600, -2072.8215) && pz <= 5.72)
|| (IsPlayerInArea(playerid, 1281.0251, 1202.2368, -2346.7451, -2414.4492) && pz <= 9.3145)
|| (IsPlayerInArea(playerid, 2012.6154, 1928.9028, -1178.6207, -1221.4043) && pz <= 18.45)
|| (IsPlayerInArea(playerid, 2326.4858, 2295.7471, -1400.2797, -1431.1266) && pz <= 22.615)
|| (IsPlayerInArea(playerid, 2550.0454, 2513.7588, 1583.3751, 1553.0753) && pz <= 9.4171)
|| (IsPlayerInArea(playerid, 1102.3634, 1087.3705, -663.1653, -682.5446) && pz <= 112.45)
|| (IsPlayerInArea(playerid, 1287.7906, 1270.4369, -801.3882, -810.0527) && pz <= 87.123)
|| (pz < 1.5)
)
{
return 1;
}
return 0;
}
Respuesta: [Duda] Entrar y salir del agua -
sergios - 02.02.2013
El problema era el:
pawn Код:
IsPlayerInZone(playerid,1808.2019,1424.5392,-2230.5024,-2347.7979
Lo he eliminado y ya funciona todo correctamente ya podre adaptar mi comando, gracias.
PD: por si alguien le interesa, el stock tiene que quedar asн:
pawn Код:
stock IsPlayerInWater(playerid)
{
new Float:FXF_wpos[3];
GetPlayerPos(playerid,FXF_wpos[0],FXF_wpos[1],FXF_wpos[2]);
if((FXF_wpos[2] > 0.00 )) { return 0; }
else if((FXF_wpos[2] < 0.00) && (FXF_wpos[2] > -1.00)) { return 1; }
else if(FXF_wpos[2] < -1.00) { return 2; }
return 0;
}
Respuesta: [Duda] Entrar y salir del agua -
OTACON - 02.02.2013
pawn Код:
stock EstaEnAgua(playerid)
{
new Animacion[32], Libreria[32];
GetAnimationName(GetPlayerAnimationIndex(playeid), Libreria, sizeof(Libreria), Animacion, sizeof(Animacion));
if(!strcmp(Libreria, "SWIM", true))
{
return 1;
}
return 0;
}