IsPlayerNearObject - Problem -
Avi Raj - 14.02.2014
Hey guys,
I made a command
pawn Код:
CMD:open(playerid, params[])
{
if(IsPlayerNearObject(playerid, 2358, 4.0))
{
GivePlayerWeapon(playerid, 24, 1000);
GivePlayerWeapon(playerid, 29, 1000);
SendClientMessage(playerid, 0xFFF000,"You had found the Box! Now you are allowed to kill");
SendClientMessage(playerid, 0xFFF000,"Some weapons have been given to you.");
}
else if(!IsPlayerNearObject(playerid, 2358, 10.0))
{
SendClientMessage(playerid, 0xFFFF00AA,"Dont Waste time.. find the box!");
}
return 1;
}
Its not working fine.
When im standing next to the object id 2358, it says :- Dont waste time... find the box!.
My IsPlayerNearObject stock :-
pawn Код:
stock IsPlayerNearObject(playerid, objectid, Float:range)
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(objectid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z))return true;
return false;
}
Can anyone help me?
thanks
Re: IsPlayerNearObject - Problem -
newbienoob - 14.02.2014
objectid is not a model. So it'd be something like;
pawn Код:
new obj = CreateObject(...);
IsPlayerNearObject(playerid, obj, 6.287);
Re: IsPlayerNearObject - Problem -
Konstantinos - 14.02.2014
GetObjectPos needs the objectid not the modelid.
EDIT: Too late.
Re: IsPlayerNearObject - Problem -
CuervO - 14.02.2014
Object ID stands for the object ID handled and returned by the script.
It is incremental, meaning it goes from 1 to whatever the limit is.
If you're trying to make it work by the model, there are two things you can do:
1) Use the streamer which stores the Model in a variable
2) Store each object ID in a variable and attach a model to that variable in another varialbe.
EDIT: Too late too.
Re: IsPlayerNearObject - Problem -
Avi Raj - 14.02.2014
it says :-
pawn Код:
error 017: undefined symbol "box1"
pawn Код:
CMD:open(playerid, params[])
{
if(IsPlayerNearObject(playerid, box1, 4.0))
{
GivePlayerWeapon(playerid, 24, 1000);
GivePlayerWeapon(playerid, 29, 1000);
SendClientMessage(playerid, 0xFFF000,"You had found the Box! Now you are allowed to kill");
SendClientMessage(playerid, 0xFFF000,"Some weapons have been given to you.");
}
else if(!IsPlayerNearObject(playerid, box1, 10.0))
{
SendClientMessage(playerid, 0xFFFF00AA,"Dont Waste time.. find the box!");
}
return 1;
}
//my object
new box1 = CreateDynamicObject(2358,2245.6762700,-1183.1665000,1028.8868400,0.0000000,0.0000000,0.0000000,.interiorid = 15); //
Re: IsPlayerNearObject - Problem -
Konstantinos - 14.02.2014
Doing:
pawn Код:
GetObjectPos(box1, X, Y, Z);
of course will not work because box1 is undefined.
pawn Код:
// global:
new box1;
// To the place you create the object:
box1 = CreateObject(...);
Re: IsPlayerNearObject - Problem -
CuervO - 14.02.2014
box1 must be defined outside any function otherwise the variable will only work within the range of said function.
Global variables are those which are defined outside any callback/function and are intended to be globally used among all the callbacks.
Local variables, are those defined within a function, they can't overlay global variables (but can overlay other local variables in other functions) and will get erased once the function has been processed.
EDIT: Ninja'd again, I hate this!
Re: IsPlayerNearObject - Problem -
Avi Raj - 14.02.2014
Tried that way too.
Still it says, Dont waste time... find the box!.
im actually next to the object.
Re: IsPlayerNearObject - Problem -
Konstantinos - 14.02.2014
After showing how you create the object changes everything. GetObjectPos will fail and you should use the functions of the streamer plugin.
pawn Код:
// global:
new box1;
// To the place you create the object:
box1 = CreateDynamicObject(2358,2245.6762700,-1183.1665000,1028.8868400,0.0000000,0.0000000,0.0000000,.interiorid = 15);
pawn Код:
stock IsPlayerNearObject(playerid, objectid, Float:range)
{
new Float:X, Float:Y, Float:Z;
GetDynamicObjectPos(objectid, X, Y, Z);
return (IsPlayerInRangeOfPoint(playerid, range, X, Y, Z));
}
Re: IsPlayerNearObject - Problem -
Avi Raj - 14.02.2014
Thanks Bro. it worked
+Repped you all.