if(strcmp(cmd, "/wanted2", true) == 0) { new count, namestr[MAX_PLAYER_NAME];//64 is too much since the max length of a name is like ~20 for(new i; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(PlayerData[i][pWantedLevel]!=0) { count++; GetPlayerName(i,namestr,MAX_PLAYER_NAME); if(!strlen(string)) { format(string,sizeof(string),"%s level: %d",namestr,PlayerData[i][pWantedLevel]); } else { format(string,sizeof(string),"\n%s level: %d",namestr,PlayerData[i][pWantedLevel]); } } } } ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel"); if(count == 0)return SendClientMessage(playerid,0xFFFFFFFF,"There are no wanted Players"); return 1; }
if(dialogid == 500) { if(!response) { return 1; } if(PlayerData[PlayerSelectedInDialog][pWantedLevel] > 0) { new Float:x, Float:y, Float:z; GetPlayerPos(PlayerSelectedInDialog, x, y, z); SetPlayerCheckpoint(playerid, x,y,z, 3.0); return 1; } }
ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel");
Код:
ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel"); |
https://sampwiki.blast.hk/wiki/OnDialogResponse
inputtext[] The text entered into the input box by the player or the selected list item text. That means if line 3 "w3b Level: 10", listitem will be 2, and inputtext will be that << You should know what to do with the rest of it .. |
if(strcmp(cmd, "/wanted2", true) == 0)
{
string[0] = EOS; // clearing string array
new namestr[MAX_PLAYER_NAME];//64 is too much since the max length of a name is like ~20
for(new i, g = GetMaxPlayers(); i < g; i++)
if(IsPlayerConnected(i))
{
if(PlayerData[i][pWantedLevel] != 0)
{
GetPlayerName(i,namestr,MAX_PLAYER_NAME);
format(string,sizeof(string),"\n%s%s level: %d",string,namestr,PlayerData[i][pWantedLevel]);
}
}
if(!string[0]) SendClientMessage(playerid,0xFFFFFFFF,"There are no wanted Players");
else ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel");
return 1;
}
if(dialogid == 500)
{
if(!response) return 1;
new pos = strfind(inputtext," ",true);
if(pos != -1)
{
inputtext[pos] = EOS;
new giveplayerid;
//giveplayerid = GetPlayerIdFromName(inputtext); you need add/find this function if there is no sscanf in your gamemode
sscanf(inputtext,"u",giveplayerid);
if(giveplayerid != INVALID_PLAYER_ID)
{
if(PlayerData[giveplayerid][pWantedLevel] > 0)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(giveplayerid, x, y, z);
SetPlayerCheckpoint(playerid, x, y, z, 3.0);
}
}
}
return 1;
}