12.02.2014, 15:38
Is there a way I can detect if a player walks through a laser object?
Regards
Regards
I think you can with Areas with the streamer plugin ( https://sampforum.blast.hk/showthread.php?tid=102865 )
|
#define MAX_LASERS 5 // your number here
enum sInfo
{
sCreated,
Float:sX,
Float:sY,
Float:sZ,
sObject,
};
new LasInfo[MAX_LASERS][sInfo];
stock CreateLas(Float:x,Float:y,Float:z,Float:Angle)
{
for(new i = 0; i < sizeof(LasInfo); i++)
{
if(LasInfo[i][sCreated] == 0)
{
LasInfo[i][sCreated]=1;
LasInfo[i][sX]=x;
LasInfo[i][sY]=y;
LasInfo[i][sZ]=z-0.7;
LasInfo[i][sObject] = CreateObject(2899, x, y, z-0.9, 0, 0, Angle-90);
return 1;
}
}
return 0;
}
public OnPlayerUpdate(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
for(new i = 0; i < sizeof(LasInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, LasInfo[i][sX], LasInfo[i][sY], LasInfo[i][sZ]))
{
// What will happen next is up to you