if(dInfo[playerid][dVar1] == 0)
{
new pID = GetPlayerID(inputtext);
if(IsPlayerConnected(pID)) // Not working as its suppose to
{
new suspected[4];
new house = GetUserHouse(pID);
if(pInfo[pID][pWanteds] >= 1) { suspected="Yes"; } else { suspected="No"; }
new string[64];
format(string, sizeof(string), "Persons Name: %s\nSuspected: %d\nHouse: %d\n", inputtext, suspected, house);
ShowPlayerDialog(playerid, GUI_MDC, DIALOG_STYLE_MSGBOX, "MDC - Person Information", string, "Ok", "");
}
else {
new query[300];
format(query, sizeof(query), "SELECT * FROM %splayers WHERE name = '%s'", SQL_PREFIX, inputtext);
mysql_query(query);
new rows = strval(query);
if(rows == 1)
{
format(query, sizeof(query), "SELECT Wanteds FROM %splayers WHERE name = '%s'", SQL_PREFIX, inputtext);
mysql_query(query);
new wanteds = strval(query);
new string[64];
format(string, sizeof(string), "Persons Name: %s\nSuspected: %d", inputtext, wanteds);
ShowPlayerDialog(playerid, GUI_MDC, DIALOG_STYLE_MSGBOX, "MDC - Person Information", string, "Ok", "");
}
else {
ShowInfoDialog(playerid, "MDC - Error", "This name does not exist in the police database.");
}
}
}
new pID = strval(inputtext);
stock GetPlayerID(const Name[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
if(strcmp(Name, pName, true)==0)
{
return i;
}
}
}
return -1;
}
if(GetPlayerID(inputtext) == -1) return SendClientMessage(playerid, -1, "Error, invalid name connected!");
new pID = GetPlayerID(inputtext);
stock GetPlayerID(Name[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
if(strcmp(Name, pName, true) == 0)
{
break;
return i;
}
}
}
return -1;
}
new pID = GetPlayerID(inputtext);
if( pID != -1 )
{
// he's connected;
}
else
{
//he's not
}
Why a stock, when it's already a function by a_samp.inc?
Returns: The ID of the player OR -1, pawn Код:
|
Important Note: This is a custom function, which can be found in Useful_Functions. |