08.04.2012, 16:50
Buenas a Todos, Alguien me podria decir para ke sirve este stock y un ejemplo como utilizarlo?.
Desde ya muchas gracias.
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;
}