Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Pewien .sma -proszę HELP


  • Zamknięty Temat jest zamknięty
7 odpowiedzi w tym temacie

#1 Biceps

    Życzliwy

  • Użytkownik

Reputacja: 0
Nowy

  • Postów:30
Offline

Napisano 22.03.2008 11:25

Witam mam taki plik sma to jest plugin jak wpisze /hats to moge sobie wybrac czapki ale jest problem bo każdy może to sobie wppisać a ja chciałem aby mogła to osoba z określoną flagą czy ktoś mógłby mi pomóc w tym bardzo bym prosił oto .sma:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new g_bwEnt[33]

#define PLUG_NAME "HATS"
#define PLUG_AUTH "SgtBane"
#define PLUG_VERS "0.2"
#define PLUG_TAG "HATS"

#define menusize 	220

new HatFile[64]
new MenuPages, TotalHats
new CurrentMenu[33]

#define MAX_HATS 64
new HATMDL[MAX_HATS][41]
new HATNAME[MAX_HATS][41]

public plugin_init()
{
	register_plugin(PLUG_NAME, PLUG_VERS, PLUG_AUTH)
	register_concmd("amx_givehat", "Give_Hat", ADMIN_RCON, "<nick> <mdl #>")
	register_concmd("amx_removehats", "Remove_Hat", ADMIN_RCON, " - Removes hats from everyone.")
	register_menucmd(register_menuid("yHat Menu: [Page"),(1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9),"MenuCommand")
	register_clcmd("amx_czapki",		"ShowMenu", -1, "Shows Knife menu")
}

public ShowMenu(id)
{
	CurrentMenu[id] = 1
	ShowHats(id)
	return PLUGIN_HANDLED
}

public ShowHats(id)
{
	new keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
	
	new szMenuBody[menusize + 1], WpnID
	new nLen = format(szMenuBody, menusize, "yHat Menu: [Page %i/%i]^n",CurrentMenu[id],MenuPages)
	
	// Get Hat Names And Add Them To The List
	for (new hatid=0; hatid < 8; hatid++) {
		WpnID = ((CurrentMenu[id] * 8) + hatid - 8)
		if (WpnID < TotalHats) {
			nLen += format(szMenuBody[nLen], menusize-nLen, "^nw %i. %s",hatid + 1,HATNAME[WpnID])
		}
	}
	
	// Next Page And Previous/Close
	if (CurrentMenu[id] == MenuPages) {
		nLen += format(szMenuBody[nLen], menusize-nLen, "^n^nd9. Next Page")
	} else {
		nLen += format(szMenuBody[nLen], menusize-nLen, "^n^nw9. Next Page")
	}
	
	if (CurrentMenu[id] > 1) {
		nLen += format(szMenuBody[nLen], menusize-nLen, "^nw0. Previous Page")
	} else {
		nLen += format(szMenuBody[nLen], menusize-nLen, "^nw0. Close")
	}
	show_menu(id, keys, szMenuBody, -1)
	return PLUGIN_HANDLED
}
public MenuCommand(id, key) 
{
	switch(key)
	{
		case 8:		//9 - [Next Page]
		{
			if (CurrentMenu[id] < MenuPages) CurrentMenu[id]++
			ShowHats(id)
			return PLUGIN_HANDLED
		}
		case 9:		//0 - [Close]
		{
			CurrentMenu[id]--
			if (CurrentMenu[id] > 0) ShowHats(id)
			return PLUGIN_HANDLED
		}
		default:
		{
			new HatID = ((CurrentMenu[id] * 8) + key - 8)
			if (HatID < TotalHats) {
				Set_Hat(id,HatID,id)
			}
		}
	}
	return PLUGIN_HANDLED
}

public plugin_precache()
{
	new cfgDir[32]
	get_configsdir(cfgDir,31)
	formatex(HatFile,63,"%s/HatList.ini",cfgDir)
	command_load()
	
	for (new i = 1; i < TotalHats; ++i) {
		if (file_exists (HATMDL[i])) {
			precache_model(HATMDL[i])
			server_print("[%s] Precached %s",PLUG_TAG,HATMDL[i])
		} else {
			server_print("[%s] Failed to precache %s",PLUG_TAG,HATMDL[i])
		}
	}
}

public client_connect(id)
{
	if(g_bwEnt[id] > 0) engfunc(EngFunc_RemoveEntity,g_bwEnt[id])
	g_bwEnt[id] = 0
}

public client_disconnect(id)
{
	if(g_bwEnt[id] > 0) engfunc(EngFunc_RemoveEntity,g_bwEnt[id])
	g_bwEnt[id] = 0
}

public Give_Hat(id)
{
	new smodelnum[5], name[32]
	read_argv(1,name,31)
	read_argv(2,smodelnum,4)
	
	new player = cmd_target(id,name,2)
	if (!player) {
		client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG)
		return PLUGIN_HANDLED
	}
	
	new imodelnum = (str_to_num(smodelnum))
	if (imodelnum > MAX_HATS) return PLUGIN_HANDLED
	
	Set_Hat(player,imodelnum,id)

	return PLUGIN_CONTINUE
}

public Remove_Hat(id)
{
	for (new i = 0; i < get_maxplayers(); ++i) {
		if (is_user_connected(i) && g_bwEnt[i] > 0) {
			engfunc(EngFunc_RemoveEntity,g_bwEnt[i])
			g_bwEnt[i] = 0
		}
	}
	client_print(id,print_chat,"[%s] Removed hats from everyone.",PLUG_TAG)
	return PLUGIN_CONTINUE
}

public Set_Hat(player,imodelnum,targeter)
{
	new name[32]
	get_user_name(player, name, 31)
	if (imodelnum == 0) {
		if(g_bwEnt[player] > 0) engfunc(EngFunc_RemoveEntity,g_bwEnt[player])
		g_bwEnt[player] = 0
		client_print(targeter, print_chat, "[%s] Removed hat from %s",PLUG_TAG,name)
	} else if (file_exists(HATMDL[imodelnum])) {
		if(g_bwEnt[player] < 1) {
			g_bwEnt[player] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
			if(g_bwEnt[player] > 0) 
			{
				set_pev(g_bwEnt[player], pev_movetype, MOVETYPE_FOLLOW)
				set_pev(g_bwEnt[player], pev_aiment, player)
				set_pev(g_bwEnt[player], pev_rendermode, kRenderNormal)
				set_pev(g_bwEnt[player], pev_renderamt, 0.0)
				engfunc(EngFunc_SetModel, g_bwEnt[player], HATMDL[imodelnum])
			}
		} else {
			engfunc(EngFunc_SetModel, g_bwEnt[player], HATMDL[imodelnum])
		}
		client_print(targeter, print_chat, "[%s] Set %s on %s",PLUG_TAG,HATNAME[imodelnum],name)
	}
}

public command_load()
{
	if(file_exists(HatFile)) {
		HATMDL[0] = ""
		HATNAME[0] = "None"
		TotalHats = 1
		new sfLineData[128]
		new file = fopen(HatFile,"rt")
		while(file && !feof(file)) {
			fgets(file,sfLineData,127)
			
			// Skip Comment and Empty Lines
			if (containi(sfLineData,";") > -1) continue
			
			// BREAK IT UP!
			parse(sfLineData, HATMDL[TotalHats],40,HATNAME[TotalHats],40)
			
			TotalHats += 1
			if(TotalHats >= MAX_HATS) {
				server_print("[%s] Reached hat limit",PLUG_TAG)
				break
			}
		}
		if(file) fclose(file)
	}
	MenuPages = floatround((TotalHats / 8.0), floatround_ceil)
	server_print("[%s] Loaded %i hats, Generated %i pages)",PLUG_TAG,TotalHats,MenuPages)
}


Próbowałem zmienic zamiasc say /hats wpisalem amx_czapki i w cmdacces wpisałem tak "amx_czapki "a" ale nadal każdy mógł sobie wybrać :/
  • +
  • -
  • 0

#2 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 22.03.2008 19:09

#include <amxmodx> 
#include <amxmisc> 
#include <fakemeta> 

new g_bwEnt[33] 

#define PLUG_NAME "HATS" 
#define PLUG_AUTH "SgtBane" 
#define PLUG_VERS "0.2" 
#define PLUG_TAG "HATS" 

#define menusize     220 
#define FLAG ADMIN_IMMUNITY   // Flaga potrzebna do menu

new HatFile[64] 
new MenuPages, TotalHats 
new CurrentMenu[33] 

#define MAX_HATS 64 
new HATMDL[MAX_HATS][41] 
new HATNAME[MAX_HATS][41] 

public plugin_init() 
{ 
    register_plugin(PLUG_NAME, PLUG_VERS, PLUG_AUTH) 
    register_concmd("amx_givehat", "Give_Hat", ADMIN_RCON, "<nick> <mdl #>") 
    register_concmd("amx_removehats", "Remove_Hat", ADMIN_RCON, " - Removes hats from everyone.") 
    register_menucmd(register_menuid("yHat Menu: [Page"),(1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9),"MenuCommand") 
    register_clcmd("amx_czapki",        "ShowMenu", -1, "Shows Knife menu") 
} 

public ShowMenu(id) 
{ 
    if(get_user_flags(id) & FLAG)
    {
         CurrentMenu[id] = 1 
         ShowHats(id) 
    }
    return PLUGIN_HANDLED 
} 

public ShowHats(id) 
{ 
    new keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9) 
    
    new szMenuBody[menusize + 1], WpnID 
    new nLen = format(szMenuBody, menusize, "yHat Menu: [Page %i/%i]^n",CurrentMenu[id],MenuPages) 
    
    // Get Hat Names And Add Them To The List 
    for (new hatid=0; hatid < 8; hatid++) { 
        WpnID = ((CurrentMenu[id] * 8) + hatid - 8) 
        if (WpnID < TotalHats) { 
            nLen += format(szMenuBody[nLen], menusize-nLen, "^nw %i. %s",hatid + 1,HATNAME[WpnID]) 
        } 
    } 
    
    // Next Page And Previous/Close 
    if (CurrentMenu[id] == MenuPages) { 
        nLen += format(szMenuBody[nLen], menusize-nLen, "^n^nd9. Next Page") 
    } else { 
        nLen += format(szMenuBody[nLen], menusize-nLen, "^n^nw9. Next Page") 
    } 
    
    if (CurrentMenu[id] > 1) { 
        nLen += format(szMenuBody[nLen], menusize-nLen, "^nw0. Previous Page") 
    } else { 
        nLen += format(szMenuBody[nLen], menusize-nLen, "^nw0. Close") 
    } 
    show_menu(id, keys, szMenuBody, -1) 
    return PLUGIN_HANDLED 
} 
public MenuCommand(id, key) 
{ 
    switch(key) 
    { 
        case 8:        //9 - [Next Page] 
        { 
            if (CurrentMenu[id] < MenuPages) CurrentMenu[id]++ 
            ShowHats(id) 
            return PLUGIN_HANDLED 
        } 
        case 9:        //0 - [Close] 
        { 
            CurrentMenu[id]-- 
            if (CurrentMenu[id] > 0) ShowHats(id) 
            return PLUGIN_HANDLED 
        } 
        default: 
        { 
            new HatID = ((CurrentMenu[id] * 8) + key - 8) 
            if (HatID < TotalHats) { 
                Set_Hat(id,HatID,id) 
            } 
        } 
    } 
    return PLUGIN_HANDLED 
} 

public plugin_precache() 
{ 
    new cfgDir[32] 
    get_configsdir(cfgDir,31) 
    formatex(HatFile,63,"%s/HatList.ini",cfgDir) 
    command_load() 
    
    for (new i = 1; i < TotalHats; ++i) { 
        if (file_exists (HATMDL[i])) { 
            precache_model(HATMDL[i]) 
            server_print("[%s] Precached %s",PLUG_TAG,HATMDL[i]) 
        } else { 
            server_print("[%s] Failed to precache %s",PLUG_TAG,HATMDL[i]) 
        } 
    } 
} 

public client_connect(id) 
{ 
    if(g_bwEnt[id] > 0) engfunc(EngFunc_RemoveEntity,g_bwEnt[id]) 
    g_bwEnt[id] = 0 
} 

public client_disconnect(id) 
{ 
    if(g_bwEnt[id] > 0) engfunc(EngFunc_RemoveEntity,g_bwEnt[id]) 
    g_bwEnt[id] = 0 
} 

public Give_Hat(id) 
{ 
    new smodelnum[5], name[32] 
    read_argv(1,name,31) 
    read_argv(2,smodelnum,4) 
    
    new player = cmd_target(id,name,2) 
    if (!player) { 
        client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG) 
        return PLUGIN_HANDLED 
    } 
    
    new imodelnum = (str_to_num(smodelnum)) 
    if (imodelnum > MAX_HATS) return PLUGIN_HANDLED 
    
    Set_Hat(player,imodelnum,id) 

    return PLUGIN_CONTINUE 
} 

public Remove_Hat(id) 
{ 
    for (new i = 0; i < get_maxplayers(); ++i) { 
        if (is_user_connected(i) && g_bwEnt[i] > 0) { 
            engfunc(EngFunc_RemoveEntity,g_bwEnt[i]) 
            g_bwEnt[i] = 0 
        } 
    } 
    client_print(id,print_chat,"[%s] Removed hats from everyone.",PLUG_TAG) 
    return PLUGIN_CONTINUE 
} 

public Set_Hat(player,imodelnum,targeter) 
{ 
    new name[32] 
    get_user_name(player, name, 31) 
    if (imodelnum == 0) { 
        if(g_bwEnt[player] > 0) engfunc(EngFunc_RemoveEntity,g_bwEnt[player]) 
        g_bwEnt[player] = 0 
        client_print(targeter, print_chat, "[%s] Removed hat from %s",PLUG_TAG,name) 
    } else if (file_exists(HATMDL[imodelnum])) { 
        if(g_bwEnt[player] < 1) { 
            g_bwEnt[player] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) 
            if(g_bwEnt[player] > 0) 
            { 
                set_pev(g_bwEnt[player], pev_movetype, MOVETYPE_FOLLOW) 
                set_pev(g_bwEnt[player], pev_aiment, player) 
                set_pev(g_bwEnt[player], pev_rendermode, kRenderNormal) 
                set_pev(g_bwEnt[player], pev_renderamt, 0.0) 
                engfunc(EngFunc_SetModel, g_bwEnt[player], HATMDL[imodelnum]) 
            } 
        } else { 
            engfunc(EngFunc_SetModel, g_bwEnt[player], HATMDL[imodelnum]) 
        } 
        client_print(targeter, print_chat, "[%s] Set %s on %s",PLUG_TAG,HATNAME[imodelnum],name) 
    } 
} 

public command_load() 
{ 
    if(file_exists(HatFile)) { 
        HATMDL[0] = "" 
        HATNAME[0] = "None" 
        TotalHats = 1 
        new sfLineData[128] 
        new file = fopen(HatFile,"rt") 
        while(file && !feof(file)) { 
            fgets(file,sfLineData,127) 
            
            // Skip Comment and Empty Lines 
            if (containi(sfLineData,";") > -1) continue 
            
            // BREAK IT UP! 
            parse(sfLineData, HATMDL[TotalHats],40,HATNAME[TotalHats],40) 
            
            TotalHats += 1 
            if(TotalHats >= MAX_HATS) { 
                server_print("[%s] Reached hat limit",PLUG_TAG) 
                break 
            } 
        } 
        if(file) fclose(file) 
    } 
    MenuPages = floatround((TotalHats / 8.0), floatround_ceil) 
    server_print("[%s] Loaded %i hats, Generated %i pages)",PLUG_TAG,TotalHats,MenuPages) 
}

Przepuscilem tylko przez kompilator czy nie zrobilem literuwek. Zmieniajac #define FLAG ... ustalasz jaka flaga jest potrzebna do menu.
  • +
  • -
  • 0

#3 MafiaDL

    Naj-Najstarszy Moderator

  • Przyjaciel

Reputacja: 561
Wszechwiedzący

  • Postów:3 492
  • GG:
  • Imię:Łukasz
  • Lokalizacja:Warsaw
Offline

Napisano 23.03.2008 00:35

mi tez sie przyda Biceps dal bys link do models czapek?:P czy mogą byc z innego pluga Miczu?
  • +
  • -
  • 0

#4 Biceps

    Życzliwy

  • Autor tematu
  • Użytkownik

Reputacja: 0
Nowy

  • Postów:30
Offline

Napisano 23.03.2008 00:42

miczu??? jak to zrobic???
#define menusize     220
#define FLAG ADMIN_IMMUNITY   // Flaga potrzebna do menu

w którym momencie? wpisać załóżmy że chce na flage "a"

ps. plik ini wrzucasz do configs folderu

na dole modele dla @up

Załączone pliki


  • +
  • -
  • 0

#5 pROgAMER

    Profesjonalista

  • Użytkownik

Reputacja: 40
Pomocny

  • Postów:196
  • Lokalizacja:Olsztyn
Offline

Napisano 23.03.2008 01:56

#define ADMIN_IMMUNITY (1<<0) /* flag "a" */

chyba tak
  • +
  • -
  • 0

#6 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 23.03.2008 11:02

Admin Level Constants: 
#define ADMIN_ALL			//Everyone
#define ADMIN_IMMUNITY		//Flag "a", immunity
#define ADMIN_RESERVATION		//Flag "b", reservation
#define ADMIN_KICK			//Flag "c", kick
#define ADMIN_BAN			//Flag "d", ban
#define ADMIN_SLAY			//Flag "e", slay
#define ADMIN_MAP			//Flag "f", map change
#define ADMIN_CVAR			//Flag "g", cvar change
#define ADMIN_CFG			//Flag "h", config execution
#define ADMIN_CHAT			//Flag "i", chat
#define ADMIN_VOTE			//Flag "j", vote
#define ADMIN_PASSWORD		//Flag "k", sv_password
#define ADMIN_RCON			//Flag "l", rcon access
#define ADMIN_LEVEL_A			//Flag "m", custom
#define ADMIN_LEVEL_B			//Flag "n", custom
#define ADMIN_LEVEL_C		//Flag "o", custom
#define ADMIN_LEVEL_D		//Flag "p", custom
#define ADMIN_LEVEL_E			//Flag "q", custom
#define ADMIN_LEVEL_F			//Flag "r", custom
#define ADMIN_LEVEL_G		//Flag "s", custom
#define ADMIN_LEVEL_H			//Flag "t", custom
#define ADMIN_MENU			//Flag "u", menus
#define ADMIN_ADMIN			//Flag "y", default admin
#define ADMIN_USER			//Flag "z", default user

pROgAMER piszesz tak bo ci nie dziala to co napisalem czy po prostu masz nadzieje na pomogl :P

Wszystkie wyzej wymienione skroty sa zdeklarowane w rdzeniu (core) amxx'a by nie stosowac tego malo mowiacego zapisu.

w którym momencie? wpisać załóżmy że chce na flage "a"

Immunity to jest wlasnie flaga a wiec nie musisz juz zmienaic :P
  • +
  • -
  • 0

#7 pROgAMER

    Profesjonalista

  • Użytkownik

Reputacja: 40
Pomocny

  • Postów:196
  • Lokalizacja:Olsztyn
Offline

Napisano 23.03.2008 11:15

nie miczus nie licz na pomógł tylko prubuje pomcu bo kolega mnie meczyl wczoraj a ty niebyles w stanie :D
  • +
  • -
  • 0

#8 MafiaDL

    Naj-Najstarszy Moderator

  • Przyjaciel

Reputacja: 561
Wszechwiedzący

  • Postów:3 492
  • GG:
  • Imię:Łukasz
  • Lokalizacja:Warsaw
Offline

Napisano 23.03.2008 14:38

Miczu nie kazdy leci na "POMÓGŁ" XDDD

Thx Biceps
  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych