Actor In Range. Help Needed -
danish007 - 26.07.2015
Hello i've Custom IsPlayerInRangeOfActor its not working fine for me if im in its range its still saying me not in range.
this is stock
pawn Код:
stock IsPlayerInRangeOfActor(playerid, actorid, Float:radius = 5.0)
{
new Float:x,
Float:y,
Float:z;
if (GetActorPos(actorid, x, y, z))
{
return IsPlayerInRangeOfPoint(playerid, radius, x, y, z);
}
return 0;
}
Actors
pawn Код:
new Actor_Bank_1;//at Rodeo
new Actor_Bank_2;//at Roca Escalante
new Actor_Bank_3;//at Kings
new Actor_Bank_4;//at Palomino Creek
new Actor_Bank_5;//at Fort Carson
new Actor_Bank_6;//at Las Barrancas
ongamemodeinit
pawn Код:
CreateActorEx(Actor_Bank_1, 147, 2311.0417, -11.0132, 26.7422, 181.5174, 72, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
CreateActorEx(Actor_Bank_2, 147, 2311.0417, -11.0132, 26.7422, 181.5174, 73, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
CreateActorEx(Actor_Bank_3, 147, 2311.0417, -11.0132, 26.7422, 181.5174, 74, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
CreateActorEx(Actor_Bank_4, 147, 2311.0417, -11.0132, 26.7422, 181.5174, 75, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
CreateActorEx(Actor_Bank_5, 147, 2311.0417, -11.0132, 26.7422, 181.5174, 76, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
CreateActorEx(Actor_Bank_6, 147, 2311.0417, -11.0132, 26.7422, 181.5174, 77, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
createactorex stock
pawn Код:
stock CreateActorEx(ActorId, modelid, Float:X, Float:Y, Float:Z, Float:Rotation, world, label[])
{
ActorId = CreateActor(modelid, X, Y, Z, Rotation);
SetActorVirtualWorld(ActorId, world);
SetActorInvulnerable(ActorId, true);
Create3DTextLabel(label, 0xFFFFFFFF, X, Y, Z + 1.2, 50.0, world, 1);
}
the command in which i've problem.
pawn Код:
COMMAND:robbery(playerid, params[])
{
new string[256];
new CPID = PlayerInfo[playerid][pCheckpoint];
if (PlayerInfo[playerid][pSpawned] == 1)
{
if (PlayerInfo[playerid][pTeam] == TEAM_CIVILIAN && PlayerInfo[playerid][pVigilante] == 0)
{
if (GetPlayerVirtualWorld(playerid) > 0)
{
if (IsPlayerInGamemodeArea(playerid))
{
if (CheckPoint[CPID][cpbustype] == BUS_TYPE_BANK)
{
if (IsPlayerInRangeOfActor(playerid, Actor_Bank_4) || IsPlayerInRangeOfActor(playerid, Actor_Bank_5))
{
format(string, sizeof(string), "You Can Only Rob Places In %s While Playing %s.",ServerInfo[sMapName],ServerInfo[sMapName]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if (IsPlayerInRangeOfActor(playerid, Actor_Bank_1) || IsPlayerInRangeOfActor(playerid, Actor_Bank_2) || IsPlayerInRangeOfActor(playerid, Actor_Bank_3))
{
if (PlayerInfo[playerid][pHoldup] > 0)
{
SendClientMessage(playerid, COLOR_ERROR, "You Are Currently Robbing The Bank. Go Away From The BOT To Cancel.");
return 1;
}
if (LocationBeingCracked[CPID] > 0)
{
SendClientMessage(playerid, COLOR_ERROR, "Someone is Currently Robbing The Bank.");
return 1;
}
if (LocationRobWaitTime[CPID] > 0)
{
SendClientMessage(playerid, COLOR_ERROR, "This Location Has Been Robbed Recently. Try Again Later.");
return 1;
}
if (PlayerInfo[playerid][pJailed] == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command In Jail.");
return 1;
}
PlayerInfo[playerid][pCrackingTime] = 25;
PlayerInfo[playerid][pHoldupAmount] = 0;
PlayerInfo[playerid][pRaceCheckpoint] = 0;
LocationBeingCracked[CPID] = 1;
PlayerInfo[playerid][pMission] = MISSION_TYPE_BANK_ROBBERY_1;
PlayerInfo[playerid][pRobberies] ++;
HideTextDrawMenu(playerid);
switch (CURRENT_GAMEMODE)
{
case LOS_SANTOS:
{
strmid(PlayerInfo[playerid][pHoldupVictim], "Los Santos Bank", 0, 128, 128);
}
case LAS_VENTURAS:
{
strmid(PlayerInfo[playerid][pHoldupVictim], "Las Venturas Bank", 0, 128, 128);
}
case SAN_FIERRO:
{
strmid(PlayerInfo[playerid][pHoldupVictim], "San Fierro Bank", 0, 128, 128);
}
}
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, "Bank Robbery In Progress... Go Away From The BOT To Cancel The Robbery.");
SendGameText(playerid,"~w~BEGINNING ~y~ROBBERY ~w~STAY NEAR THE ~p~BOT~n~~y~ROBBERY IN PROGRESS");
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You Must Be Near The BOT To Begin The Bank Robbery.");
}
}
}
else
{
format(string, sizeof(string), "You Can Only Rob Places In %s While Playing %s.",ServerInfo[sMapName],ServerInfo[sMapName]);
SendClientMessage(playerid, COLOR_ERROR, string);
}
}
else
SendClientMessage(playerid, COLOR_ERROR, "You Must Be Inside The Robbery Place To Begin A Robbery.");
}
else
SendClientMessage(playerid, COLOR_ERROR, "Law Enforcement Agents Cannot Rob Places.");
}
else
SendErrorMessage(playerid, MSG_NOT_SPAWNED);
return 1;
}
its not working not letting me rob the bank even im in range of actor.
it keep showing me this message.
pawn Код:
SendClientMessage(playerid, COLOR_ERROR, "You Must Be Near The BOT To Begin The Bank Robbery.");
+rep help needed.
Re: Actor In Range. Help Needed -
TwinkiDaBoss - 26.07.2015
pawn Код:
forward IsPlayerInRangeOfActor(playerid, actorid, Float:radius = 5.0);
stock IsPlayerInRangeOfActor(playerid, actorid, Float:radius = 5.0)
{
new
Float:x,
Float:y,
Float:z;
if (GetActorPos(actorid, x, y, z))
{
return IsPlayerInRangeOfPoint(playerid, radius, x, y, z) && GetPlayerInterior(playerid) == GetActorInterior(actorid);
}
return 0;
}
Credits to Emmet_
Re: Actor In Range. Help Needed -
Evocator - 26.07.2015
Im afraid CreateActorEx doesnt pass arguments as you are doing it, i suggest:
Код:
stock CreateActorEx(modelid, Float:X, Float:Y, Float:Z, Float:Rotation, world, label[])
{
new
actorid = CreateActor(modelid, X, Y, Z, Rotation);
SetActorVirtualWorld(actorid , world);
SetActorInvulnerable(actorid , true);
Create3DTextLabel(label, 0xFFFFFFFF, X, Y, Z + 1.2, 50.0, world, 1);
return actorid;
}
Actor_Bank_1 = CreateActorEx(147, 2311.0417, -11.0132, 26.7422, 181.5174, 72, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
Actor_Bank_2 = CreateActorEx(147, 2311.0417, -11.0132, 26.7422, 181.5174, 73, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
Actor_Bank_3 = CreateActorEx(147, 2311.0417, -11.0132, 26.7422, 181.5174, 74, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
Actor_Bank_4 = CreateActorEx(147, 2311.0417, -11.0132, 26.7422, 181.5174, 75, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
Actor_Bank_5 = CreateActorEx(147, 2311.0417, -11.0132, 26.7422, 181.5174, 76, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
Actor_Bank_6 = CreateActorEx(147, 2311.0417, -11.0132, 26.7422, 181.5174, 77, ""WHITE"Press "YELLOW"Y "WHITE"For "CYAN"Bank Services");
Edit: Also you dont need to SetActorInvulnerable as they spawn invulnerable.
Re: Actor In Range. Help Needed -
danish007 - 26.07.2015
it worked Thank YoU!