11.05.2015, 15:43
pawn Код:
CMD:checkweapons(playerid, params[])
{
if(!GetPVarInt(playerid, "LoggedIn")) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be logged in to use this command.");
if(Player[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_GREY, ADMIN);
new id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "[Server Command]: /checkweapons [playerid]");
if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: That player is not connected.");
new weapons[13][2], string[150];
for(new i = 0; i < 13; i++)
{
new fstr[12];
GetPlayerWeaponData(id, i, weapons[i][0], weapons[i][1]);
if(weapons[i][0])
{
format(fstr, sizeof(fstr), "Slot %i: %i\n", i, weapons[i][0]);
strcat(string, fstr);
}
}
ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Player's Client-Side Weapons", string, "OK", "");
format(string, sizeof(string), "%s's account weapons:", GetName(id));
SendClientMessage(playerid, COLOR_LIGHTRED, string);
format(string, sizeof(string), "{C0C0C0}Slot 1: {FFFFFF}%i{C0C0C0} - Slot 2: {FFFFFF}%i{C0C0C0} - Slot 3: {FFFFFF}%i", Player[id][Weapon1], Player[id][Weapon2], Player[id][Weapon3]);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string), "{C0C0C0}Slot 4: {FFFFFF}%i{C0C0C0} - Slot 5: {FFFFFF}%i{C0C0C0} - Slot 6: {FFFFFF}%i", Player[id][Weapon4], Player[id][Weapon5], Player[id][Weapon6]);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string), "{C0C0C0}Slot 7: {FFFFFF}%i{C0C0C0} - Slot 8: {FFFFFF}%i{C0C0C0} - Slot 9: {FFFFFF}%i", Player[id][Weapon7], Player[id][Weapon8], Player[id][Weapon9]);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string), "{C0C0C0}Slot 10: {FFFFFF}%i{C0C0C0} - Slot 11: {FFFFFF}%i{C0C0C0} - Slot 12: {FFFFFF}%i", Player[id][Weapon10], Player[id][Weapon11], Player[id][Weapon12]);
SendClientMessage(playerid, COLOR_GREY, string);
SendClientMessage(playerid, COLOR_LIGHTRED, "Note: If their client-side weapons don't match their account weapons, they are weapon hacking.");
return 1;
}
https://sampwiki.blast.hk/wiki/Strcat
https://sampwiki.blast.hk/wiki/Format
https://sampwiki.blast.hk/wiki/Keywords:Statements#for
EDIT:
Also, I recommend that you use arrays for your player weapons instead of all those different elements... like Weapon1, Weapon2, Weapon3 etc.
'enum blahblah
{
Weapon[13]
//blah blah...
}'