[Duda] stock ReturnUser(text[])... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [Duda] stock ReturnUser(text[])... (
/showthread.php?tid=332567)
[Duda] stock ReturnUser(text[])... -
OTACON - 08.04.2012
Buenas a Todos, Alguien me podria decir para ke sirve este stock y un ejemplo como utilizarlo?.
Desde ya muchas gracias.
PHP код:
stock ReturnUser(text[])
{
new pos = 0;
new userid = RETURN_USER_FAILURE;
while(text[pos] < 0x21) { // Strip out leading spaces
if(text[pos] == 0) return RETURN_USER_FAILURE; // No passed text
pos++;
}
if(isNumeric(text[pos])) { // Check whole passed string
userid = strval(text[pos]);
if(userid >=0 && userid < MAX_PLAYERS)
{
if(IsPlayerConnected(userid)) return userid;
return RETURN_USER_FAILURE;
}
}
// 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+1];
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;
}
else { // Partial match
count++;
userid = i;
}
}
}
}
if(!count) return RETURN_USER_FAILURE;
if(count > 1) return RETURN_USER_MULTIPLE;
return userid;
}
Respuesta: [Duda] stock ReturnUser(text[])... -
TheChaoz - 08.04.2012
Devuelve el id de un usuario en base al id ingresado (algo obvio), el nombre, o parte del nombre.
Respuesta: [Duda] stock ReturnUser(text[])... -
OTACON - 08.04.2012
mirando bien si, es el tipico ReturnUser pero mas elaborado xDD, es ke me hizo confundir por ke le pusieron text[] XDD :P.