/locate cmd
#1

hey guys, i am trying to make a command where i can /locate another player.
when i locate them, it will send me a message saying "Player(id) has been Located in Ganton"

im using this filterscript as my servers gps system.

https://sampforum.blast.hk/showthread.php?tid=94353

is there a way, somewhere in that script that i can add a /locate cmd?

thanks

edit: this was my attempt lol, i know it makes no sense whatsoever

Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{

	new cmd[256];

    if(success)
    {
        return 1;
    }

	if(strcmp(cmd, "/loc", true) == 0)
    {
    new str[256];
    for(new i=0; i<gMax; i++)
    format(str,sizeof(str),"%s", GetPlayerArea(i));
    SendClientMessage(playerid, COLOR_YELLOW, str);
    return 1;
	}
	return 0;
}
Reply
#2

Are you using zcmd?
Reply
#3

either one because i alternate between both depending on my script
Reply
#4

ZCMD commands are like callbacks, don't put your commands in another functions.


For this type of commands(with parameters), you can use sscanf
pawn Код:
CMD:loc(playerid, params[])
{
    new ID;
    if(sscanf(params, "u",ID))
        return SendClientMessage(playerid, -1, "/loc [ID]");

    new str[36];
    format(str,sizeof(str),"%s", GetPlayerArea(ID));
    SendClientMessage(playerid, COLOR_YELLOW, str);
    return 1;
}
Reply
#5

okay, i added in what you said but i got the error "error 017: undefined symbol "params"

here's the top of my script

Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
what could be wrong?

--------------------------------------------------------------------------------------

edit: no problemo, had to add the params there CMD:loc(playerid, params[])

thanks with the help, but i'd like it to say "Player(ID) is Located in "AREA"

how would i go about adding the players name and id there also?

also rep + for the help!
Reply
#6

Just change this line
pawn Код:
format(str,sizeof(str),"Player(%d) is located in %s", ID, GetPlayerArea(ID));
If you need the exact name, use GetPlayerName
Reply
#7

Quote:
Originally Posted by ViniBorn
Посмотреть сообщение
Just change this line
pawn Код:
format(str,sizeof(str),"Player(%d) is located in %s", ID, GetPlayerArea(ID));
If you need the exact name, use GetPlayerName
Using getplayername is such a waste of time, I always use this instead:
pawn Код:
stock PlayerName(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, 24);
    return name;
}
e.g: PlayerName(targetid);
Reply
#8

Okay I'll give it a crack! Thanks for the help
Reply
#9

like you neeed /find cmd as a detactive job?
Reply
#10

Quote:
Originally Posted by XaibBaba
Посмотреть сообщение
like you neeed /find cmd as a detactive job?
Question has already been answered.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)