Find Command with SetPlayerCheckpoint -
dreamboxxl - 13.06.2012
Hi, i 've tried to use this code here, to locate a player on the map.
if(strcmp("/find", cmdtext, true) == 0)
{
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, rot, "Verwendung: /find [spielerid]");
new pID;
pID = ReturnUser(playerid);
if(IsPlayerConnected(pID) && pID != playerid)
{
new name[24], string[128];
GetPlayerName(pID, name, sizeof name);
format(string, sizeof string,"Du hast die Suche nach %s gestartet !",name);
SendClientMessage(playerid, rot, string);
SetTimerEx("Suchen", 1000, 1, "ii",playerid,pID);
}
return 1;
}
forward Suchen(playerid, pID);
public Suchen(playerid, pID)
{
if(IsPlayerConnected(pID))
{
new Float: X, Float: Y, Float: Z;
GetPlayerPos(pID, X, Y, Z);
SetPlayerCheckpoint(playerid, X, Y, Z, 3.0);
}
else
{
DisablePlayerCheckpoint(playerid);
}
return 1;
}
In Pawn i got this error:
error 017: undefined symbol "ReturnUser"
So i found a stock for it and added this stock to the end of the script.
Now i got only one more error after compiling:
error 035: argument type mismatch (argument 1)
it's this line here:
pID = ReturnUser(playerid);
So maybe someone could help me please?
Thank You
Re: Find Command with SetPlayerCheckpoint -
Yuryfury - 13.06.2012
It should be
not
Also, this ReturnUser function supposedly works fine:
pawn Код:
stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21) // Strip out leading spaces
{
if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos])) // Check whole passed string
{
// If they have a numeric name you have a problem (although names are checked on id failure)
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
{
userid = INVALID_PLAYER_ID;
}
else
{
return userid; // A player was found
}
}
}
// They entered [part of] a name or the id search failed (check names just incase)
new len = strlen(text[pos]);
new count = 0;
new name[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof (name));
if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
{
if (len == strlen(name)) // Exact match
{
return i; // Return the exact player on an exact match
}
else // Partial match
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count)
{
SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow search.");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "No matching user found.");
}
}
userid = INVALID_PLAYER_ID;
}
return userid; // INVALID_PLAYER_ID for bad return
}
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
Re: Find Command with SetPlayerCheckpoint -
dreamboxxl - 13.06.2012
Thank You!
Now i got no more errors while compiling.
But now the command gives me ingame : unknown command.
Greets