09.11.2016, 11:04
Hello,
so i want to obtain the name of the player, but ONLY if the player is offline.
This doesn't work, and I have no idea why.
Can someone help me?
ty
So, nothing gets send to the chat (sendclientmessage doesn't work.)
so i want to obtain the name of the player, but ONLY if the player is offline.
This doesn't work, and I have no idea why.
Can someone help me?
ty
PHP код:
/* ============================================================================= */
COMMAND:foff(playerid,params[])
{
if(!Player[playerid][Faction]) return SendClientError(playerid,"You are not in a faction.");
new query[200];
format(query,sizeof(query),"SELECT * FROM accounts WHERE Faction='%i'",Player[playerid][Faction]);
mysql_tquery(connection,query,"foff","d",playerid);
return 1;
}
/* ============================================================================= */
forward foff(playerid);
public foff(playerid)
{
new name[35];
for(new i=0; i<cache_get_row_count(); i++)
{
cache_get_field_content(i,"Username",name);
if(IsPlayerConnected(GetPlayerID(name))) return 1;
SendClientMessage(playerid,-1,sprintf("%i",i));
}
return 1;
}
/* ============================================================================= */
stock GetPlayerID(playername[])
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new playername2[MAX_PLAYER_NAME];
GetPlayerName(i, playername2, sizeof(playername2));
if(strcmp(playername2, playername, true, strlen(playername)) == 0)
{
return i;
}
}
}
return INVALID_PLAYER_ID;
}
/* ============================================================================= */