3 posts,
2 people · 1,057 views
Thread Rating: ★★★★★
| closedGiving items upon respawn |
| Started by Tank on 12-07-2009, 11:45 AM |
started this thread
Posts: 581Threads: 59
Joined: Jan 2007
12-07-2009, 11:45 AM
#1
Lets say I want to let a player choose their own melee weapon. Is there a faster way then just making the player drop all their weapons and regive what he had plus their chose for melee weapon?rnrn
public stripme(id)rn{rn if(is_user_connected(id))rn {rn strip_user_weapons(id)rn set_task(0.3,"givetheshit",id)rn }rn}rnrnAnd givetheshit being a function where everything is given to the player.rnrnIf this is the only way, set_task is the only command to use to time schedule a function to occur? Getting a bit many tasks since regiving items at the same time don't work.posted here
Posts: 776Threads: 75
Joined: Nov 2007
12-07-2009, 02:19 PM
#2
Once opon a time i wanted the same thing basicly, but i did it like this:rnrn
#include <amxmodx>rn#include <fakemeta>rn#include <hamsandwich>rn////////////////////////////////////////////////////////////////////////////////////////////////////rn#define PLUGIN "DoD Melee...thing"rn#define VERSION "1.0 by Dr.G"rn#define AUTHOR "AMXX DoD Team"rn////////////////////////////////////////////////////////////////////////////////////////////////////rnnew const KNIFES[][] = { rn "weapon_amerknife", rn "weapon_spade", rn "weapon_gerknife" rn} rn////////////////////////////////////////////////////////////////////////////////////////////////////rnpublic plugin_init ()rn{rn register_plugin(PLUGIN, VERSION, AUTHOR)rn rn RegisterHam(Ham_Spawn,"player","func_HamSpawn") rn rn for (new i = 0; i < sizeof KNIFES; i++) rn RegisterHam(Ham_DOD_Item_CanDrop, KNIFES[i], "func_Drop") rn rn register_clcmd ( "say /melee", "iMeleeMenu" );rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnpublic iMeleeMenu(id)rn{rn rn new menu = menu_create("
Pick your melee:", "menu_handler");rn menu_additem(menu, "wGerman spade", "1", 0);rn menu_additem(menu, "wAllied knife", "2", 0);rn menu_additem(menu, "wGerman knife", "3", 0);rn rn menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);rn rn menu_display(id, menu, 0);rn rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnpublic menu_handler(id, menu, item)rn{rn if( item == MENU_EXIT )rn {rn menu_destroy(menu);rn return PLUGIN_HANDLED;rn }rn rn new data[6], iName[64];rn new access, callback;rn menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);rn rn new key = str_to_num(data);rn rn switch(key)rn {rn case 1:rn {rn client_cmd(id, "slot1")rn set_task(0.5, "give_spade", id)rn menu_destroy(menu);rn return PLUGIN_HANDLED;rn }rn case 2:rn {rn client_cmd(id, "slot1")rn set_task(0.5, "give_allied_k", id)rn menu_destroy(menu);rn return PLUGIN_HANDLED;rn }rn case 3: rn {rn client_cmd(id, "slot1")rn set_task(0.5, "give_ger_k", id)rn menu_destroy(menu);rn return PLUGIN_HANDLED;rn }rn rn }rn rn menu_destroy(menu);rn return PLUGIN_HANDLED;rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnpublic Enable_Drop(iEnt) rn{ rn SetHamReturnInteger(1)rn return HAM_SUPERCEDE rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnpublic give_allied_k(id)rn{rn client_cmd(id, "drop")rn ham_give_weapon(id,"weapon_amerknife")rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnpublic give_ger_k(id)rn{rn client_cmd(id, "drop")rn ham_give_weapon(id, "weapon_amerknife")rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnpublic give_spade(id)rn{rn client_cmd(id, "drop")rn ham_give_weapon(id,"weapon_spade")rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnstock ham_give_weapon(id,weapon[])rn{rn if(!equal(weapon,"weapon_",7)) return 0;rn rn new wEnt = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,weapon));rn if(!pev_valid(wEnt)) return 0;rn rn set_pev(wEnt,pev_spawnflags,SF_NORESPAWN);rn dllfunc(DLLFunc_Spawn,wEnt);rn rn if(!ExecuteHamB(Ham_AddPlayerItem,id,wEnt))rn {rn if(pev_valid(wEnt)) set_pev(wEnt,pev_flags,pev(wEnt,pev_flags) | FL_KILLME);rn return 0;rn }rn rn ExecuteHamB(Ham_Item_AttachToPlayer,wEnt,id)rn return 1;rn}rn////////////////////////////////////////////////////////////////////////////////////////////////////rnrnrnI cant remember if i ever got i tested right tho... Might be confusing for some that they can drop there knife hehe, but... its soon christmas and strange stuff happens.rnrnFor striping one weapon, hmmm, try this maybe, got it from arkshine some time ago:rnrnrnstock ham_strip_weapon( const id, const WeapIndex )rn {rn ExecuteHamB( Ham_Weapon_RetireWeapon, WeapIndex );rn ExecuteHamB( Ham_RemovePlayerItem, id, WeapIndex );rn ExecuteHamB( Ham_Item_Kill, WeapIndex );rn rn set_pev( id, pev_weapons, pev( id, pev_weapons) & ~( 1 << WeapIndex ) ); rn }rnrnrn- Cheersstarted this thread
Posts: 581Threads: 59
Joined: Jan 2007
12-09-2009, 04:52 PM
#3
Can't test the plugin since it's not complete but it sure looks like something I can work with, thank you...just need to read up on using hamsandwich stuff, never burned my fingers on that, would be about time :D

