/hire, when someone is near to you
#1

I made a command /hire [id] with which the leader of any faction can /hire people to his faction. Okay, the command working but I want to make only when the TARGET is nearly to him.

I mean, something like this

When he isn't near to you
/hire 1 ---- The person isn't nearly to you

When he's near to you
/hire 1 ---- plInfo[playerid][pRank] = 1.........

Would someone help me?
Reply
#2

Use ProxDetectorS:
pawn Код:
ProxDetectorS(Float:radi, playerid, targetid) {
        new
            Float: fp_playerPos[3];

        GetPlayerPos(targetid, fp_playerPos[0], fp_playerPos[1], fp_playerPos[2]);

        if(IsPlayerInRangeOfPoint(playerid, radi, fp_playerPos[0], fp_playerPos[1], fp_playerPos[2]) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid))
        {
            return 1;
        }
    return 0;
}
Reply
#3

Thanks, I will try it!

I tried something different, and .. failed xD

Код:
 public OnPlayerText(playerid, text[])
{
	new message[128];
	format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
	if(ProxDetectorS(30.0, playerid, targetid)
	{
	ProxDetector(30.0, playerid, message, COLOR_WHITE);
	}
	if(ProxDetectorS(60.0, playerid, targetid)
	{
	ProxDetector(60.0, playerid, message, COLOR_GREY);
	}

	return 0;
}
error 017: undefined symbol "targetid" x2
Reply
#4

Not that lol show the /hire strcmp cmd
Reply
#5

Hmm, watch your code carefully:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid; // You didn't define "targetid"
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid)
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }
    if(ProxDetectorS(60.0, playerid, targetid)
    {
    ProxDetector(60.0, playerid, message, COLOR_GREY);
    }

    return 0;
}
Reply
#6

Quote:
Originally Posted by ToiletDuck
Посмотреть сообщение
Not that lol show the /hire strcmp cmd
I made /hire command, but now I have problem with this -.-

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
Thanks, I will try it!

I tried something different, and .. failed xD

Код:
 public OnPlayerText(playerid, text[])
{
	new message[128];
	format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
	if(ProxDetectorS(30.0, playerid, targetid)
	{
	ProxDetector(30.0, playerid, message, COLOR_WHITE);
	}
	if(ProxDetectorS(60.0, playerid, targetid)
	{
	ProxDetector(60.0, playerid, message, COLOR_GREY);
	}

	return 0;
}
error 017: undefined symbol "targetid" x2
Reply
#7

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
I made /hire command, but now I have problem with this -.-
No, you should put that under /hire cmd before the function..

Post your /hire cmd and i'll try to explain.
Reply
#8

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
I made /hire command, but now I have problem with this -.-
My post may help you ^^
Reply
#9

Hm, new problem.

Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid;
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid))
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }
    if(ProxDetectorS(60.0, playerid, targetid))
    {
    ProxDetector(60.0, playerid, message, COLOR_GREY);
    }

    return 0;
}
When I type something in the chat, it appears two times. ex:

Danny taylon says: test ( in white ) and then
Danny Taylon says: test (in grey) xD
Reply
#10

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
Hm, new problem.

Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid;
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid))
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }
    if(ProxDetectorS(60.0, playerid, targetid))
    {
    ProxDetector(60.0, playerid, message, COLOR_GREY);
    }

    return 0;
}
When I type something in the chat, it appears two times. ex:

Danny taylon says: test ( in white ) and then
Danny Taylon says: test (in grey) xD
Remove ProxDetectorS:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid;
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid))
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }

    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)