CMD:weaps(playerid, params[])
{
if (!IsPlayerAdmin(playerid)) return 1;
new
id;
if (sscanf(params, "r", id)) return SendClientMessage(playerid, -1, "Usage: /weaps <ID/Part Of Name>");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
new
weaponid,
ammo,
sz_T[32];
GetPlayerName(id, sz_T, MAX_PLAYER_NAME);
format( sz_T, sizeof (sz_T), "%s's weapons:", sz_T);
SendClientMessage(playerid, -1, sz_T);
for (new i; i != 13; ++i)
{
GetPlayerWeaponData(id, i, weaponid, ammo);
format(sz_T, sizeof (sz_T), "weaponid: %d & ammo: %d", weaponid, ammo);
SendClientMessage(playerid, -1, sz_T);
}
return 1;
}
//under OnPlayerCommand
dcmd(weaps,5,cmdtext);
//dcmd command
dcmd_weaps(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new pID, weaposL[320];
if(sscanf(params, "u",pID))return SendClientMessage(playerid,0xFF0000FF,"Usage: /checkwep [ID]");
if(!IsPlayerConnected(pID))return SendClientMessage(playerid,0xFF0000FF,"Player ID/Name not found!");
if(pID == INVALID_PLAYER_ID)return SendClientMessage(playerid,0xFF0000FF,"This PlayerId is invalid!");
new weapons[13][2],weaponsName[13][32];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(pID, i, weapons[i][0], weapons[i][1]);
switch(weapons[i][0])
{
case 0:weaponsName[i]="Unarmed";
case 1:weaponsName[i]="Brass Knuckles";
case 2:weaponsName[i]="Golf Club";
case 3:weaponsName[i]="Nightstick";
case 4:weaponsName[i]="Knife";
case 5:weaponsName[i]="Baseball Bat";
case 6:weaponsName[i]="Shovel";
case 7:weaponsName[i]="Pool Cue";
case 8:weaponsName[i]="Katana";
case 9:weaponsName[i]="Chainsaw";
case 10:weaponsName[i]="Dildo 1";
case 11:weaponsName[i]="Dildo 2";
case 12:weaponsName[i]="Vibrator 1";
case 13:weaponsName[i]="Vibrator 2";
case 14:weaponsName[i]="Flowers";
case 15:weaponsName[i]="Cane";
case 16:weaponsName[i]="Grenade";
case 17:weaponsName[i]="Tear Gas";
case 18:weaponsName[i]="Molotov Cocktail";
case 22:weaponsName[i]="9mm Pistol";
case 23:weaponsName[i]="9mm Pistol silenced";
case 24:weaponsName[i]="Desert Eagle";
case 25:weaponsName[i]="Shotgun";
case 26:weaponsName[i]="SawnOff Shotgun";
case 27:weaponsName[i]="Combat Shotgun";
case 28:weaponsName[i]="Micro SMG";
case 29:weaponsName[i]="MP5";
case 30:weaponsName[i]="Ak47";
case 31:weaponsName[i]="M4";
case 32:weaponsName[i]="Tec9";
case 33:weaponsName[i]="Country Rifle";
case 34:weaponsName[i]="Sniper Rifle";
case 35:weaponsName[i]="RPG";
case 36:weaponsName[i]="Heat Seeker Rocket";
case 37:weaponsName[i]="Flamethrower";
case 38:weaponsName[i]="Minigun";
case 39:weaponsName[i]="Satchel Charge";
case 40:weaponsName[i]="Detonator";
case 41:weaponsName[i]="Sprycan";
case 42:weaponsName[i]="Fire Extinguisher";
case 43:weaponsName[i]="Camera";
case 44:weaponsName[i]="Night Vision Goggles";
case 45:weaponsName[i]="Thermal Goggles";
case 46:weaponsName[i]="Parachute";
default:weaponsName[i]="NONE";
}
format(weaposL, sizeof weaposL, "%s Weapon: %s | Ammo: %d\r\n", weaposL, weaponsName[i], weapons[i][1]);
}
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX,"{EE0000}Weaponlist", weaposL, "Ok", "");
new name[24],string[128];
GetPlayerName(pID,name,24);
format(string,sizeof(string),"{00FF7F}%s's current weapon data is displayed below...",name);
SendClientMessage(playerid,0xFF0000FF,string);
}else return SendClientMessage(playerid, 0xFF0000FF, "You are not an admin!");
return 1;
}
CMD:weaps(playerid, params[])
{
new
PlayerWeapons[13], PlayerAmmo[13],
WeaponName[30], string[100],
targetid, i = 1
;
if( sscanf ( params, "u", targetid ) )
return SendClientMessage(playerid, -1, "Syntax: /weaps [Player Name/ID]");
while(i <= 12)
{
GetPlayerWeaponData( id, i, PlayerWeapons[ i ], PlayerAmmo[ i ] );
if( PlayerWeapons[ i ] != 0 )
{
GetWeaponName( PlayerWeapons[i], WeaponName, sizeof( WeaponName ) );
format( string, sizeof( string ) , "Weapon ID: [%d] Weapon Name: [%s] - Ammo: [%d]", PlayerWeapons[ i ], WeaponName, PlayerAmmo[ i ] );
SendClientMessage( playerid, -1, string );
}
i++;
}
return true;
}
@pds2k12: i know there are more effective ways to do it but i dont think codes posted here just should be copied
into the script by the thread starter! I dont know about you but me as a newbie in scripting would have problems to fully follow certain codes. It always helped me to see different codes doing same or simillar stuff so i could understand and later combine everything to try out things on my own. Unfortunately it has become pretty common to serve everything on a silver plate and invite newbies to just C&P codes instead of asking questions and being able to fully understand it. I didnt want the thread starter to simply copy my code into his script, i just wanted to show how it also works, as my foreposter already posted a full code and i think you can easily see how the loop/GetPlayerWeaponData function works on my example. I at least always appreciated more examples of certain systems/functions to think about it and see certain differences. regards, wolf. |