[Pawn] Help with Custom Weapon Names - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Help with Custom Weapon Names (/showthread.php?tid=1269) |
Help with Custom Weapon Names - RoBy41 - 2020-10-23 Lately I noticed that Roleplay servers scripts allow weapons with the same ID (for example, a Deagle) to be stored in a player's inventory under different names. For example, if a player (from Grove Street Families)?has a Deagle on him, if he does /inventory (hypothetically), instead of Deagle, the weapon's name is ''Glock''. Also, let's say there is another player (from Ballas) that has a Deagle on him. But in this case, the weapon's name?(Deagle) can be another weapon name other than Glock (that the first player has), for example, when the second player does /inventory, the name of the Deagle is ''Beretta''. How can you do that? RE: Help with Custom Weapon Names - Awide - 2020-10-24 Are you using Teams??You can set them under SetPlayerSpawnInfo or SetPlayerTeam.?I guess you have, so you would be able to use https://www.open.mp/docs/scripting/functions/GetPlayerTeam Code: new string[128]; RE: Help with Custom Weapon Names - Kwarde - 2020-10-24 There are multiple ways to do it. Personally, I would use an array holding all the desired weapon names, something like this: Code: enum To print the name of a weapon: Code: weaponName[weaponid][teamid] For example, to print "Combat knife": Code: weaponName[WEAPON_KNIFE][TEAM_LEO] I find that more convenient than using switches. But go with whatever you like best, especially since some weapons may not even need custom/different names. When using this script like this you need to define names for all possible weapons and all possible teams, otherwise you will have either compile errors or runtime errors because arrays might go out of bounds. If you would remove WEAPON_BAT in this example, using WEAPON_CHAINSAW would cause out of bounds error and WEAPON_SHOVEL to WEAPON_KATANA would print the wrong name. RE: Help with Custom Weapon Names - RoBy41 - 2020-10-24 Thank you both for answering. I was very confused about this matter. But I don't want the weapon name to be dependent on the player's team (I provided the GSF/Ballas info hypothetically, I meant to describe 2 different players so you would understand I want different names for the same weapon). I'll try to link the const weaponname to a command like /makeweapon, a command that only the faction that has the ability to make weapons will be able to use and see if I can get a result since I'm a newbie at scripting. RE: Help with Custom Weapon Names - Expert* - 2020-10-24 - Grove gang member gives his weapon (X) to ballas gang member. Did that weapon name change to what ballas gang member should have ? If yes - look at examples above. If no - It's inventory system that is handeling weapon names ( DMG, weight, and so on ) and its not actually based on teams. It's too complicated to be explained in a single post if you want to do it in proper way. If you can't give items and/or weapons to another player - if i had to guess, it's inventory based. Otherwise it's really cheap way to make your gun sys unique... RE: Help with Custom Weapon Names - RoBy41 - 2020-10-24 (2020-10-24, 10:55 AM)Expert* Wrote: - Grove gang member gives his weapon (X) to ballas gang member. Yes, you are right. An inventory system.?I just thought and I'll try to learn to script an inventory with custom weapon names instead, because I'm aware it's kind of complicated to get help from the others here. |