| Rudi Antoni |
08-08-2012 21:57 |
[HELP] Functions with weapons, extra items for ZP VIP
1 Attachment(s)
Sorry for my english =( i'm brazilian, and my english is weak.
This is my first plugin xD.
I'm trying to do three plugins that have a certain relationship:
"zp_vip_extra_g3sg1.amxx" - gives G3SG1 Auto-Sniper to player
"zp_vip_extra_sg550.amxx" - gives SG550 Auto-Sniper for the player.
"zp_vip_extra_m249.amxx" - gives M249 Machinegun for the player.
Each has two characteristics: the name and cost.
These settings are determined according to an external file
called "zp_extraitems_vip.ini".
These settings can be customized.
These plugins should work as follows:
When the player tries to buy vip G3SG1, will only be given if the conditions are met:
1. If the current round the player has not yet purchased.
2. If the current round the player has purchased, but was infected, and then was cured, it can again buy the gun.
3. If he does not possess any other weapons
(in this case, the SG550 Auto-Sniper or M249 Machinegun).
4. If he has any of the other weapons
(in this case SG550 Auto-Sniper or M249 Machinegun)
and drop any of them, he can buy the Auto-Sniper G3SG1.
The other plugins work the same way. This means that in the case of condition 3,
it might just buy the SG550 if it does not possess G3SG1 neither M249.
Or in the case of condition 4, he could only buy the SG550 if he dropped the G3SG1 or M249.
For now, I could only make the G3SG1, SG550 and M249 plugins obey only conditions 1 and 2.
Below, the code of the "zp_vip_extra_g3sg1.amxx" plugin.
PHP Code:
// // Item extra para jogadores humanos VIPs: TEC TEC TR // Extra item for human VIP players: G3SG1 Auto Sniper // #include <amxmodx> #include <fun> #include <hamsandwich> #include <amx_settings_api> #include <zmvip> #include <zombieplague> #include <zp50_colorchat> #define COMPRIMENTO_MAXIMO 32 // Arquivo de configuração // Settings file new const ARQUIVO_DE_ITENS_VIP[] = "zp_extraitems_vip.ini" // Padrões // Defaults new const item_arma[]= {"weapon_g3sg1"} // ID de munições para armas // Ammo id new const id_municao[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10, 1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 } new const tipo_municao[][] = { "", "357sig", "", "762nato", "", "buckshot", "", "45acp", "556nato", "", "9mm", "57mm", "45acp", "556nato", "556nato", "556nato", "45acp", "9mm", "338magnum", "9mm", "556natobox", "buckshot", "556nato", "9mm", "762nato", "", "50ae", "556nato", "762nato", "", "57mm" } new const pente_max_municao[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120, 30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 } // Soma de bits de armas primárias // Primary weapons birsum const SOMA_BITS_G3SG1 = ((1<<CSW_G3SG1)) new g_item_id_g3sg1 new g_name_g3sg1[COMPRIMENTO_MAXIMO] = "G3SG1 Auto-Sniper" new g_cost_g3sg1 = 0 new bool: g_possui_g3sg1[33] public plugin_init() { register_plugin("[ZP VIP] G3SG1 VIP", "1.0", "Rudi Antoni") register_event("DeathMsg", "morte", "a") RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1) } public client_connect(id) { g_possui_g3sg1[id] = false } public client_disconnect(id) { g_possui_g3sg1[id] = false } public fwHamPlayerSpawnPost(id) { g_possui_g3sg1[id] = false } public morte() { g_possui_g3sg1[read_data(2)] = false } public plugin_precache() { // Carregar de um arquivo externo, caso falhar, salve nesse arquivo // Load from a external file, if fail, save in this file. // NAME (nome) if(!amx_load_setting_string(ARQUIVO_DE_ITENS_VIP, "G3SG1 Auto-Sniper", "NAME", g_name_g3sg1, charsmax(g_name_g3sg1))) amx_save_setting_string(ARQUIVO_DE_ITENS_VIP, "G3SG1 Auto-Sniper", "NAME", g_name_g3sg1) // COST (custo) if(!amx_load_setting_int(ARQUIVO_DE_ITENS_VIP, "G3SG1 Auto-Sniper", "COST", g_cost_g3sg1)) amx_save_setting_int(ARQUIVO_DE_ITENS_VIP, "G3SG1 Auto-Sniper", "COST", g_cost_g3sg1) g_item_id_g3sg1 = zv_register_extra_item(g_name_g3sg1, "[ZP VIP] Sniper automatica G3SG1", g_cost_g3sg1, ZP_TEAM_HUMAN) } public zp_user_infected_post(id) { if (zp_get_user_zombie(id)) { g_possui_g3sg1[id] = false } } public zv_extra_item_selected(player, itemid) { if (itemid==g_item_id_g3sg1) { if(g_possui_g3sg1[player] == true) { zp_colored_print(player, "So e permitido comprar ^x04(1) %s^x01 por round.",g_name_g3sg1) return; } if(g_possui_g3sg1[player] == false) { give_item(player, item_arma) ExecuteHamB(Ham_GiveAmmo, player, id_municao[24], tipo_municao[24], pente_max_municao[24]) g_possui_g3sg1[player] = true } } }
Another difficulty is that I do not know what functions to use or where to put them in code.
Note: I'm trying to do this, for the player vip can carry two primary weapons, they are:
The weapon that he chose at the beginning of the round normally, and the vip weapon.
I have no knowledge of most functions, but I'm a programmer in C language,
and also know something about the pawn. In fact, I started writing code
to plugins from CS 1.6 not long ago. I started just because I would like
to have fun with my plugins.
If you want to see the settings file, it will be available for download.
Now, thanks to those who give me support.
PS: For now, my knowledge source has been the AlliedModders Wiki.
If someone knows something about learning how to script (for beginners) like links, and others,
please send me everything you have, I'm very interested to learn how to script.
|