So noobish you might roll your eyes - Thanks.
#1

What's the mistake here, and I am a VERY new beginner, I went by instinct, can you tell me the mistake, not fix and give it? I want to fix it by myself - the only way to learn! Command is to tele player to the nearest building .
Код:
CMD:top(playerid,params[])
{
	GetPlayerPos(playerid, new float X, new float Y, new float Z);
	if (IsPlayerInRangeOfPoint() == IsValidObject())
	{
	GetObjectPos(objectid,new float x, new float y, new float z);
	SetPlayerPos(x,y,z+10);
	}
	else
	SendClientMessage(playerid, -1, "No building nearby.");
 return 1;
 }
Reply
#2

It's quite hard to explain the problem here but I can give you the answer.
Reply
#3

1. the isplayerinrangeofpoint code is wrong
if commands work like this
if(something == something)

2. It wont work because you will be teleported to where you are standing as it is also a valid object
3.getplayerpos wont work if you put new float x or something in the x y and z params..u need to create the variables and then put the name later
3.getobjectpos also has the same problem as getplayerpos
4.after the else statement u need to open and close curly brackets { }
Reply
#4

You mean this ?

pawn Код:
CMD:top(playerid,params[])
{
    #pragma unused params
    new Float:x, Float:y, Float:z; // Creating 3 Variables for coords
    GetPlayerPos(playerid, x, y, z); // Getting Player Pos
    new Float:nearest = 99999.0, object = -1;
    for(new o = 0; i < MAX_OBJECTS; o++) // Checking the nearest build
    {
        if(IsValidObject(o) && GetPlayerDistanceFromPoint(playerid, x, y, z) < nearest)
        {
            object = o;
            nearest = GetPlayerDistanceFromPoint(playerid, x, y, z);
        }
    }
    if(object == -1)
    {
        SendClientMessage(playerid, -1, "No building nearby.");
    }
    else
    {
        new Float:ox, Float:oy, Float:oz;
        GetObjectPos(object, ox, oy, oz);
        SetPlayerPos(playerid, ox + 2, oy + 1, oz);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)