PDA

View Full Version : How do i create a /getweapons with all weapons being displayed


GwENiko
19/04/2014, 02:25 AM
Hi, i wanted to know how do i create a /checkweapons where all guns are being displayed ex:

Melee:[guname] [ammo] --- Handgun:[gunname][ammo] and etc...

I have no idea how to do this :/

Flake.
19/04/2014, 03:31 AM
You could create arrays defining all the handguns, assault rifles etc.. then when someone uses the checkweapons command it'll match with them.

GwENiko
19/04/2014, 03:47 AM
This is how i am trying, but as you see i do not know specifically how to match weapons with the array number that represents the weapon ID...

CMD:weapons(playerid, params[])
{
new string[128], pID, pname[MAX_PLAYER_NAME];
if(pInfo[playerid][Level] < 1) return 0;
if(sscanf(params, "u", pID)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /getweapons");
for(new i; i< 12; i++)
{
GetPlayerWeaponData(pID, i, pgun[i][0]);
GetPlayerName(pID, pname, sizeof(pname));
format(string, sizeof(string), "============ Checking %s's Current Weapons =============", pname);
SendClientMessage(playerid, 0xFF0000AA, string);
format(string ,sizeof(string), "[WEAPON: %s][AMMO: %d]", guns[pgun[i][0]], guns[pgun[i][1]]);
SendClientMessage(playerid, 0xFF0000AA, string);
}
return 1;
}

GwENiko
19/04/2014, 09:22 PM
bump. On this code it only shows "[Weapon: Fist][Ammo: ], i want it to show everything else that the player has in other slots.

Ramoboss
19/04/2014, 10:07 PM
CMD:weapons(playerid, params[])
{
new string[128], pname[MAX_PLAYERS_NAME];
if(pInfo[playerid][Level] < 1) return 0;
if(sscanf(params, "u", pID)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /getweapons");
for(new i; i< 13; i++)
{
new guns[13][2];
GetPlayerWeaponData(playerid, i, guns[i][0]);
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "============ Checking %s's Current Weapons =============", pname);
SendClientMessage(playerid, 0xFF0000AA, string);
format(string ,sizeof(string), "[WEAPON: %s][AMMO: %d]", guns[i][0], guns[i][1]);
SendClientMessage(playerid, 0xFF0000AA, string);
}
return 1;
}


try this

awsomedude
19/04/2014, 10:21 PM
Try this instead:

CMD:weapons(playerid, params[])
{
new string[128], pID, pname[MAX_PLAYER_NAME];
if(pInfo[playerid][Level] < 1) return 0;
if(sscanf(params, "u", pID)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /getweapons");
GetPlayerName(pID, pname, sizeof(pname));
format(string, sizeof(string), "============ Checking %s's Current Weapons =============", pname);
SendClientMessage(playerid, 0xFF0000AA, string);
for(new i; i< 13; i++)
{
GetPlayerWeaponData(playerid, i, pgun[i][0], pgun[i][1]);
format(string ,sizeof(string), "[Slot:%d] [WEAPON: %s] [AMMO: %d]", i, guns[pgun[i][0]], pgun[i][1]);
SendClientMessage(playerid, 0xFF0000AA, string);
}
return 1;
}

GwENiko
20/04/2014, 04:58 AM
I have this code pre-defined in this array with the intention to name guns

new guns[][] =
{
"Fist", "Brass Knuckles", "Golf Club", "Night Stick", "Knife", "Baseball Bat", "Shove", "Cane", "Katana", "Flowers", "Small Dildo", "Medium Dildo", "Big Dildo", "Giant Dildo",
"Grenade", "Smoke Grenade", "Molotov-Cocktail", "Chainsaw", "9mm Pistol", "Silenced 9mm Pistol", "Desert Eagle", "Micro-Uzi", "TEC-9", "MP5", "Pump Shotgun", "Sawn-off Shotgun", "Combat Shotgun", "AK-47, M4", "Country Rifle", "Scoped Sniper Rifle", "Parachute", "Rocket Launcher", "Heat-Seeker", "Flamethrower",
"Minigun", "Fire Extinguisher", "Night Vision Goggles", "Thermal Heat Goggles", "Camera", "Spray Can", "Satchel Charges", "Detonator", "Pool clue"
};
new pgun[12][2];

[hr]


CMD:weapons(playerid, params[])
{
new string[128], pID, pname[MAX_PLAYER_NAME];
if(pInfo[playerid][Level] < 1) return 0;
if(sscanf(params, "u", pID)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /getweapons");
GetPlayerName(pID, pname, sizeof(pname));
format(string, sizeof(string), "============ Checking %s's Current Weapons =============", pname);
SendClientMessage(playerid, 0xFF0000AA, string);
for(new i; i< 13; i++)
{
GetPlayerWeaponData(playerid, i, pgun[i][0], pgun[i][1]);
format(string ,sizeof(string), "[Slot:%d] [WEAPON: %s] [AMMO: %d]", i, guns[pgun[i][0]], pgun[i][1]);
SendClientMessage(playerid, 0xFF0000AA, string);
}
return 1;
}

And whenever i go ig and check my weapons with the code above this is what happens:


[02:05:54] ============ Checking GwE_Niko's Current Weapons =============

[02:05:54] [Slot:0] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:1] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:2] [WEAPON: Pump Shotgun] [AMMO: 9999] // Desert Eagle

[02:05:54] [Slot:3] [WEAPON: AK-47, M4] [AMMO: 9999] // Combat Shotgun

[02:05:54] [Slot:4] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:5] [WEAPON: Rocket Launcher] [AMMO: 9999] // M4

[02:05:54] [Slot:6] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:7] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:8] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:9] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:10] [WEAPON: Fist] [AMMO: 0]

[02:05:54] [Slot:11] [WEAPON: Fist] [AMMO: 0]

[02:05:54] SERVER: Unknown command.

Dragon2
20/04/2014, 08:47 AM
You have to use textdraw or list dialog and then list the weapons and for command put giveplayerweapon

GwENiko
20/04/2014, 09:13 PM
You have to use textdraw or list dialog and then list the weapons and for command put giveplayerweapon

I dont think thats whats wrong.

Maime
20/04/2014, 09:23 PM
Fist is not a weapon fist is fist, just remove it from the list and the script will run just fine.

GwENiko
20/04/2014, 09:59 PM
Fist is not a weapon fist is fist, just remove it from the list and the script will run just fine.
It changes nothing

tyler12
20/04/2014, 09:59 PM
new slots[][] = {" ","meelee","handgun"... etc};
new guns[][] =
{
"Fist", "Brass Knuckles", "Golf Club", "Night Stick", "Knife", "Baseball Bat", "Shove", "Cane", "Katana", "Flowers", "Small Dildo", "Medium Dildo", "Big Dildo", "Giant Dildo",
"Grenade", "Smoke Grenade", "Molotov-Cocktail", "Chainsaw", "9mm Pistol", "Silenced 9mm Pistol", "Desert Eagle", "Micro-Uzi", "TEC-9", "MP5", "Pump Shotgun", "Sawn-off Shotgun", "Combat Shotgun", "AK-47, M4", "Country Rifle", "Scoped Sniper Rifle", "Parachute", "Rocket Launcher", "Heat-Seeker", "Flamethrower",
"Minigun", "Fire Extinguisher", "Night Vision Goggles", "Thermal Heat Goggles", "Camera", "Spray Can", "Satchel Charges", "Detonator", "Pool clue"
};

CMD:getweapons(playerid,params[])
{
new string[128],wData[13][2],name[24],id;
if(sscanf(params,"u",id)) return SendClientMessage(playerid,0xAA0000AA,"USAGE: /getweapons [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xAA0000AA,"ERROR: Player not connected.");
GetPlayerName(id,name,sizeof(name));
format(string, sizeof(string), "============ Checking %s's Current Weapons =============", name);
SendClientMessage(playerid, 0xAA0000AA, string);
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid,i,wData[i][0],wData[i][1]);
if(wData[i][0] == 0) continue; // avoid fists
format(string,sizeof(string),"%s: %s (%d ammo)",slots[i],guns[wData[i][0]],wData[i][1]);
SendClientMessage(playerid,-1,string);
}
return 1;
}

stock GetWeaponSlot(wid) // credit to whoever made this
{
switch(wid)
{
case 0, 1: return 0;
case 2..9: return 1;
case 22..24: return 2;
case 25..27: return 3;
case 28, 29, 32: return 4;
case 30, 31: return 5;
case 33, 34: return 6;
case 35..38: return 7;
case 16..19, 39: return 8;
case 41..43: return 9;
case 10..15: return 10;
case 44..46: return 11;
case 40: return 12;
default: return -1;
}
return -1;
}

GwENiko
21/04/2014, 01:42 PM
I tried tyler12's way and it actually works to an extent. See below

[10:49:51] ============ Checking GwE_Niko's Current Weapons =============

[10:49:51] Handgun: Sawn-off Shotgun (9959 ammo)

[10:49:51] Shotgun: M4 (9999 ammo)

[10:49:51] Rifle: Rocket Launcher (9999 ammo)

It says sawn-off on the place of desert eagle, M4 instead of Combat Shotgun, and Rifle + Rocket Launcher instead of Automatic Rifle and M4, i dont have the other weapons on me at all.



new slots[7][]=
{
"", "Melee Weapon", "Handgun", "Shotgun", "Automatic Rifle", "Rifle", "Other"
};
new guns[43][] =
{
"Brass Knuckles", "Golf Club", "Night Stick", "Knife", "Baseball Bat", "Shove", "Cane", "Katana", "Flowers", "Small Dildo", "Medium Dildo", "Big Dildo", "Giant Dildo",
"Grenade", "Smoke Grenade", "Molotov-Cocktail", "Chainsaw", "9mm Pistol", "Silenced 9mm Pistol", "Desert Eagle", "Micro-Uzi", "TEC-9", "MP5", "Combat Shotgun", "Sawn-off Shotgun", "Pump Shotgun", "AK-47", "M4", "Country Rifle", "Scoped Sniper Rifle", "Parachute", "Rocket Launcher", "Heat-Seeker", "Flamethrower",
"Minigun", "Fire Extinguisher", "Night Vision Goggles", "Thermal Heat Goggles", "Camera", "Spray Can", "Satchel Charges", "Detonator", "Pool clue"
};

CMD:getweapons(playerid,params[])
{
new string[128],wData[13][2],name[24],id;
if(sscanf(params,"u",id)) return SendClientMessage(playerid,0xAA0000AA,"USAGE: /getweapons [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xAA0000AA,"ERROR: Player not connected.");
GetPlayerName(id,name,sizeof(name));
format(string, sizeof(string), "============ Checking %s's Current Weapons =============", name);
SendClientMessage(playerid, 0xAA0000AA, string);
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid,i,wData[i][0],wData[i][1]);
if(wData[i][0] == 0) continue;
format(string,sizeof(string),"%s: %s (%d ammo)",slots[i],guns[wData[i][0]],wData[i][1]);
SendClientMessage(playerid,-1,string);
}
return 1;
}



stock GetWeaponSlot(wid)
{
switch(wid)
{
case 0, 1: return 0;
case 2..9: return 1;
case 22..24: return 2;
case 25..27: return 3;
case 28, 29, 32: return 4;
case 30, 31: return 5;
case 33, 34: return 6;
case 35..38: return 7;
case 16..19, 39: return 8;
case 41..43: return 9;
case 10..15: return 10;
case 44..46: return 11;
case 40: return 12;
default: return -1;
}
return -1;
}

DerickClark
21/04/2014, 02:01 PM
I tried tyler12's way and it actually works to an extent. See below



It says sawn-off on the place of desert eagle, M4 instead of Combat Shotgun, and Rifle + Rocket Launcher instead of Automatic Rifle and M4, i dont have the other weapons on me at all.



new slots[7][]=
{
"", "Melee Weapon", "Handgun", "Shotgun", "Automatic Rifle", "Rifle", "Other"
};
new guns[43][] =
{
"Brass Knuckles", "Golf Club", "Night Stick", "Knife", "Baseball Bat", "Shove", "Cane", "Katana", "Flowers", "Small Dildo", "Medium Dildo", "Big Dildo", "Giant Dildo",
"Grenade", "Smoke Grenade", "Molotov-Cocktail", "Chainsaw", "9mm Pistol", "Silenced 9mm Pistol", "Desert Eagle", "Micro-Uzi", "TEC-9", "MP5", "Combat Shotgun", "Sawn-off Shotgun", "Pump Shotgun", "AK-47", "M4", "Country Rifle", "Scoped Sniper Rifle", "Parachute", "Rocket Launcher", "Heat-Seeker", "Flamethrower",
"Minigun", "Fire Extinguisher", "Night Vision Goggles", "Thermal Heat Goggles", "Camera", "Spray Can", "Satchel Charges", "Detonator", "Pool clue"
};

CMD:getweapons(playerid,params[])
{
new string[128],wData[13][2],name[24],id;
if(sscanf(params,"u",id)) return SendClientMessage(playerid,0xAA0000AA,"USAGE: /getweapons [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xAA0000AA,"ERROR: Player not connected.");
GetPlayerName(id,name,sizeof(name));
format(string, sizeof(string), "============ Checking %s's Current Weapons =============", name);
SendClientMessage(playerid, 0xAA0000AA, string);
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid,i,wData[i][0],wData[i][1]);
if(wData[i][0] == 0) continue;
format(string,sizeof(string),"%s: %s (%d ammo)",slots[i],guns[wData[i][0]],wData[i][1]);
SendClientMessage(playerid,-1,string);
}
return 1;
}



stock GetWeaponSlot(wid)
{
switch(wid)
{
case 0, 1: return 0;
case 2..9: return 1;
case 22..24: return 2;
case 25..27: return 3;
case 28, 29, 32: return 4;
case 30, 31: return 5;
case 33, 34: return 6;
case 35..38: return 7;
case 16..19, 39: return 8;
case 41..43: return 9;
case 10..15: return 10;
case 44..46: return 11;
case 40: return 12;
default: return -1;
}
return -1;
}
Removed

GwENiko
21/04/2014, 08:44 PM
Removed

sorry what?

GwENiko
27/04/2014, 02:30 AM
bump