public itminfo(id,cel){ // po najechaniu na item pokazuje co to za item
static clas[32];
pev(cel,pev_classname,clas,31);
if (!equali(clas,"przedmiot")) return PLUGIN_CONTINUE
set_hudmessage(255, 170, 0, 0.3, 0.56, 0, 6.0, 0.1)
show_hudmessage(id, "Nazwa itemu: %s ",item_name[cel])
return PLUGIN_CONTINUE
}
public create_itm(id,id_item,name_item[128]){
new Float:origins[3]
pev(id,pev_origin,origins); // pobranie coordow gracza
new entit=create_entity("info_target") // tworzymy byt
origins[0]+=40.0
origins[2]-=32.0
set_pev(entit,pev_origin,origins) //ustawiamy coordy
entity_set_model(entit,modelitem) // oraz model
set_pev(entit,pev_classname,"przedmiot"); // i klase
dllfunc(DLLFunc_Spawn, entit);
set_pev(entit,pev_solid,SOLID_BBOX);
set_pev(entit,pev_movetype,MOVETYPE_FLY);
engfunc(EngFunc_SetSize,entit,{-1.1, -1.1, -1.1},{1.1, 1.1, 1.1});
engfunc(EngFunc_DropToFloor,entit);
item_info[entit]=id_item //parametry przepisujemy do globalnej tablicy potrzebnej nam potem
item_name[entit]=name_item
}
public fwd_touch(ent,id)
{
if(!is_user_alive(id)) return FMRES_IGNORED;
static classname[32];
pev(ent,pev_classname,classname,31);
if(!equali(classname,"przedmiot")) return FMRES_IGNORED; // jesli nie dotykamy przedmiotu to nie idziemy dalej
if(!player_item_id[id] && pev(id,pev_button)& IN_DUCK){ // jesli dotykamy kucamy i nie mamy itemu to go dostajemy (podnoszenie itemu - dotkniecie i duck)
award_item(id,item_info[ent])
engfunc(EngFunc_RemoveEntity,ent);
}
return FMRES_IGNORED;
}