Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

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

[WS] Weapon Storage Crates 1.0b


  • Zamknięty Temat jest zamknięty
Brak odpowiedzi do tego tematu

#1 baku

    [M]anchester[U]nited

  • Przyjaciel

Reputacja: 452
Wszechobecny

  • Postów:1054
  • Steam:steam
  • Imię:Rafał
  • Lokalizacja:Polska
Offline

Napisano 16.04.2008 19:26

A wiec chcialem spolszczyc ten plugin ale wystepuja błedy :/ Nie wiem dalczego zawsze mam takiego pecha ..

.sma :

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <fun>
#include <cstrike>

#define PLUGIN "Weapon Storage"
#define VERSION "1.0"
#define AUTHOR "Oren and Nir (oRNY & Whenn)"

#define OK PLUGIN_CONTINUE
#define EMPTY -1
#define ITEMS 500
#define BOX_MDL "models/w_ammocrate.mdl"
#define SHOW_MESSAGE 180.0
#define NEAR 50
#define EVERYONE 0
#define PRIMARY_WEAPONS ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_GALIL) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_P90))

#define W_NONE 0
#define W_PRIMARY 1
#define W_SECONDARY 2
#define W_KNIFE 3
#define W_GRENADE 4
#define W_BOMB 5


enum details
{
	WEAPON,
	TEAM,
	AMMO
}


new W_NAMES[31][] = {"","p228","","Scout","HE Grenade","xm1014","C4","mac10","aug","Smoke Grenade","Elite","Fiveseven","ump45","sg550","Galil","Famas","Usp","Glock18","Awp","Mp5","m249","m3","m4a1","tmp","g3sg1","Flashbang","Desert eagle","sg552","AK47","Knife","p90"}

new g_index //The last item's index
new g_items[ITEMS][3] //The items array
new g_origin[2][3] //Stores the box's origins
new g_boxmodel[34] //Stores the model's file
new g_box[2] //The boxes entities array
new g_menu[33],g_admin_menu[33] //Menu handlers
new g_help[101],g_help_admin[101] //Needed to store the help text
new g_first_round_text[201],g_first_round //Stores the message for the first round, a counter which determines if it's the first round or not.
new g_WEAPON_SOUND_D[] = "items/ammopickup2.wav" //The weapon depositing sound
new g_WEAPON_SOUND_W[] = "items/gunpickup2.wav" //The weapon withdrawing sound
new g_draws[33] //Withdraws per round per player
new DEFAULT[64]="dataweaponstoragedefaults.wsg"
new FILE[64]="dataweaponstorage.wsg"
new g_on,g_teamlimit,g_maxitems



public plugin_init() //Init the plugin,commands,forwards,events... everything
{
	//Register the plugin himself
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	
	//Register the cvars
	g_on=register_cvar("ws_on","1") //Turns on/off the whole mod
	register_cvar("ws_save","1") //Weather to save the items when changeing map or restarting the server
	g_teamlimit=register_cvar("ws_teamlimited","1") //If the T can use the CT's box and vice versa
	g_maxitems=register_cvar("ws_maxitems","10") //How many items can each team save
	register_cvar("ws_limituse","0") //Withdrawing per round per player or 0 for unlimited
	register_cvar("ws_random","0") //Whether to let the user choose his weapon or not
	
	
	//Register the commands
	
	//Help commands:
	register_clcmd("say /wshelp","show_help")
	register_clcmd("say_team /wshelp","show_help")
	register_clcmd("say_team wshelp","show_help")
	register_clcmd("say wshelp","show_help")
	
	//Admin commands:
	register_clcmd("ws_help","show_admin_help",ADMIN_SLAY,"Shows help for admins")
	register_clcmd("ws_admin","menu_admin_show",ADMIN_SLAY,"Shows the admin menu")
	register_clcmd("ws_ban","cmd_ban",ADMIN_SLAY,"<name>")
	register_clcmd("ws_unban","cmd_unban",ADMIN_SLAY,"<name>")
	
	
	//Register the events
	register_logevent("event_roundend", 2, "1=Round_End") //Round end event
	register_event("ResetHUD", "event_newround", "b") //New round event
	
	
	
	//Adjust the file's path
	path_init()
	
	
	//Init the help mesages
	help_init()
	
	
	//Load the items
	data_load()
	
	
	//Constantly show some text every SHOW_MESSAGE (constant) seconds
	set_task(SHOW_MESSAGE,"show_text")
}
public plugin_precache() //Used to load the models used
{
	//We prepare the box model
	precache_model(BOX_MDL)
	//And copy it's file to a global variable
	copy(g_boxmodel,32,BOX_MDL)
}
public client_PreThink(id) //Used to determine when a player is using the box
{
	//Which team is he in
	new team=get_user_team(id)
	if ( (team==3) || (!is_user_alive(id)) || (!get_pcvar_num(g_on)) ) return OK // Stop the function if he is a spectator or dead or the mod si disabled
	
	
	//Get the current button pressed and the last one as well
	new button=get_user_button(id),oldbutton=get_user_oldbutton(id)
	
	
	//If he just pressed USE (not if he holds USE)
	if ( (button&32)&&!(oldbutton&32) )
	{	
		//Check if the cvar "ws_maxitems" was changed
		event_maxitems(get_pcvar_num(g_maxitems))
		
		//Instead of reading the cvar twice
		new teamlimit=get_pcvar_num(g_teamlimit)
		
		
		//Check if he is near his box (or if he is not teamlimited if he his near any box)
		if( (player_near(id,g_origin[(team==2)?0:1]))&&(teamlimit) )
			//Show the menu
			menu_build(id)
			
		else if ( ((player_near(id,g_origin[0]))||(player_near(id,g_origin[1])))&&!(teamlimit) )
			//Else just show the menu
			menu_build(id)
			
	}

	//Exit
	return OK
}
public showhud(index,mess[]) //Show a message to a player
{
	//Adjust the message
	set_hudmessage(255, 0, 0, -1.0, 0.01)
	
	//Display the message
	show_hudmessage(index,mess)
}
public showhudtoall(mess[]) //Show a message to all players
{
	//Adjust the message
	set_hudmessage(255, 0, 0, -1.0, 0.01)
	
	//Display the message
	show_hudmessage(EVERYONE,mess)
}
stock ExplodeString(p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter) //Splits a string with the given delimeter
{
	new nIdx = 0, l = strlen(p_szInput)
	new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
	while( (nLen < l) && (++nIdx < p_nMax) )
		nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
	return
}
stock str_to_cords(Input[],Output[3]) //Turn "1,1,1" into an origin array
{
	//Declare variables
	new splitted[6][7]
	ExplodeString(splitted,3,6,Input,',')
	
	//Turn them into numbers and store them in the output variable
	Output[0]=str_to_num(splitted[0])
	Output[1]=str_to_num(splitted[1])
	Output[2]=str_to_num(splitted[2])
	
	//End
	return
}
public boxes_init() //Init the boxes
{
	new key1[64],key2[64],map[34],mess[201]
	
	//Retrive the current map's name
	get_mapname(map,63)
	
	format(key1,63,"WS_%s_CT",map)
	format(key2,63,"WS_%s_T",map)
	
	//See if we have the boxe's origins in this map
	if ( (!vaultdata_exists(key1)) || (!vaultdata_exists(key2)) )
	{
		//The message that the whole server will see in a moment
		mess="[WS] Ta mapa nie ma pozycji pudełek zapisanych^n^nJeżeli jesteś adminem proszę wpisac:^ nws_help aby utworzyc pudelka."
		
		//Disable the mod
		set_cvar_num("ws_on",0)
		set_cvar_num("ws_save",0)
	}
	else
	{
		//The message that the whole server will see in a moment
		mess="[WS]Dane tej mapy zostaly pomyslnie zaladowane :)"
		//Variables to store the data
		new data1[64],data2[64]
		//Now store the data
		get_vaultdata(key1,data1,63)
		get_vaultdata(key2,data2,63)
		
		
		
		//Now is the time to deal with them and insert them into the global array
		str_to_cords(data1,g_origin[0])
		str_to_cords(data2,g_origin[1])
		
		
		new float:temporigin[3] //Because entity_set_origin needs the origin too be float
		
		//Time to put the boxes into the game
		for (new i=0;i<2;i++)
		{
			//Remove it if it exists
			if (g_box[i])
				remove_entity(g_box[i])
				
				
			//Create an entity
			g_box[i] = create_entity("info_target") 
			
			//Change it's name
			entity_set_string(g_box[i], EV_SZ_classname, "box") 
			//Change it's model to the box's model
			entity_set_model(g_box[i], g_boxmodel) 
			
			//Position it
			float_origin(g_origin[i],temporigin)
			entity_set_origin(g_box[i], temporigin) 
			
			//Make it solid and unmovable
			entity_set_int(g_box[i],EV_INT_solid,SOLID_BBOX)
			entity_set_int(g_box[i], EV_INT_movetype, 13) 
			
			//Adjust it's size
			entity_set_size(g_box[i],{-16.0,-16.0,0.0},{16.0,16.0,18.0})
		}
	}
	
	//Display the message at the first round
	g_first_round_text=mess
}
public menu_admin_show(id) //Show the admin menu
{
	//Build the menu
	menu_admin_build(id)
	
	//Display the menu
	menu_display(id,g_admin_menu[id],0)
	
	return PLUGIN_HANDLED
}
public menu_admin_do(id, menu, item) //Handle the admin menu
{
	//If it is "Exit" we won't handle it
	if( item < 0 ) return OK
	
	
	//Get item info
	new cmd[3]
	new access, callback
 
	menu_item_getinfo(menu, item, access, cmd,2,_,_, callback)
	
	//Turn the result into a number
	new iChoice = str_to_num(cmd)
	
	
	//Declare some variables
	new key1[34],key2[34],map[34],mess[201],bBefore
	
	//Retrive the current map's name
	get_mapname(map,63)
	
	format(key1,33,"WS_%s_CT",map)
	format(key2,33,"WS_%s_T",map)
	
	//Check if we have both box origins
	bBefore=( (vaultdata_exists(key1)) && (vaultdata_exists(key2)) )
	
	
	//See if he chose to respawn the boxes
	if (iChoice==3)
	{
		//We can only do this if we have both origins
		if (!bBefore)
		{
			//Show him a message
			showhud(id,"[WS]Nie mozesz ponownie rozmnozyc pudelek bez ustawiania ich miejsc.")
		}
		else
		{
			//Remove the old boxes
			remove_entity(g_box[0])
			remove_entity(g_box[1])
			
			//Init them again
			boxes_init()
			
			//Show him a message
			showhud(id,"[WS]Gotowy")
		}
		
		//Show him the meuu again
		menu_admin_show(id)
		
		//Exit
		return OK
	}
	if (iChoice==4) //Read the origins from the defaults file and write them with vault
	{
		//If the file does not exist
		if (!(file_exists(DEFAULT)))
		{
			//Tell the user
			showhud(id,"[WS]Nie ma zadnego domyslnego pliku")
			//Bye bye
			return OK
		}
		
		//Variables ...
		new line=0, text[64], txtlen,data[2][64]
		
		//Loop and read every line of the file
		while ((line=read_file(DEFAULT,line,text,63,txtlen)))
		{
			if ( (strlen(text)>2)&&!(equali(text,";",1)) )
			//Format the line
			ExplodeString(data,2,63,text,';')
			
			//And then store it
			set_vaultdata(data[0],data[1])
		}
		
		//Inform the user
		showhud(id,"[WS]The defaults where loaded.^nYou can now use respawn boxes to respawn them at their default location")
		
		//And then show the menu again
		menu_admin_show(id)
		
		//Adios amigos
		return OK
	}
		
	
	//A variable to store the player's origin
	new origin[3]
	//Now get the player's origin
	get_user_origin(id,origin)
	
	
	//Choose the team's name by the user's choice and format the key's name
	new bNow,key[34]
	
	if (iChoice==1)
		key=key1
	else
		key=key2
		

	//Format the value
	new data[34]
	format(data,33,"%i,%i,%i",origin[0],origin[1],origin[2])
	
	//And save the data
	set_vaultdata(key,data)
	
	//Check if we have both box origins
	bNow=( (vaultdata_exists(key1)) && (vaultdata_exists(key2)) )
	
	
	//Form the message
	format(mess,200,"[WS]Dane zapisane.")
	
	//See if we didn't have both box origins before and now we do
	if (bNow && !bBefore)
	{
		set_cvar_num("ws_on",1)
		//Then add some text to his message and by that inform him that he can now choose the option "Respawn boxes" + renable the mod
		add(mess,200,"^nWeapon storage mod is now renabled.^nYou can now respawn the boxes.")
	}
		
	//Display the message to the admin
	showhud(id,mess)
	
	
	//Show the meun again
	menu_admin_show(id)
	
	//Exit
	return OK
}
public menu_admin_build(id) //Build the admin menu
{
	//Destroy the old menu
	if (g_admin_menu[id])
		menu_destroy(g_admin_menu[id])
		
		
	//Create the menu
	g_admin_menu[id] = menu_create("Weapon Storage Panel Admina PL","menu_admin_do")
	
	//Save CT box origin
	menu_additem(g_admin_menu[id],"Zachowaj aktualne miejsce pudelka dla CT","1")
	//Save T box origin
	menu_additem(g_admin_menu[id],"Zachowaj aktualne miejsce pudelka dla TT","2")
	//Respawn boxes
	menu_additem(g_admin_menu[id],"Ponownie rozmnoz pudelka","3")
	//Restore the defaults
	menu_additem(g_admin_menu[id],"Przywroc domyslne miejsce","4")
}
public help_init() //Init the help screens
{
	//The users help
	format(g_help,100,"Aby wziąć z pudelka bron nacisnij E")
	//The admins help
	format(g_help_admin,100,"Wpisz w konsoli aby otworzyc menu admina ^"ws_admin ^".")
}
public show_help(id) //Show the user's help screen
{
	//Show the help message to the user who typed /help
	show_motd(id,g_help,"Weapon storage help")
}
public show_admin_help(id) //Show the admin's help screen
{
	//Show the help message to the admin who typed ws_help in his cosole
	show_motd(id,g_help_admin,"Weapon storage help")
}
public show_text() //Show some text about the plugin every SHOW_MESSAGE (constant) seconds
{
	//If the mod is enabled then show the message
	if ( (get_cvar_num("ws_on")) )
		client_print(0,print_chat,"[WS]Ten serwer uzywa ^" Weapon Storage ^" mod, say / wshelp aby zobaczyc wiecej informacji
.")
	
	//Set a tase to show it again
	set_task(SHOW_MESSAGE,"show_text")
}
public event_newround() //A new round event, fired in every new round. Used here to show some text on the first round
{
	//Reset the players withdraws per round
	for (new i=0;i<33;i++)
		g_draws[i]=0
		
		
	//Every newround check if the cvar "ws_maxitems" was changed
	event_maxitems(get_cvar_num("ws_maxitems"))
	
	//Init the boxes
	boxes_init()
	
	//We don't need it to count anymore then up to 2
	if (g_first_round>2) return OK
	
	//The rounds counter
	g_first_round++
	
	
	//If it's the first round (yes,the first round is the "second" one because this event is fiered one time before the first round
	if (g_first_round==2)
		show_start_text
	
	
	//Exit
	return OK
}
public bool:player_near(index,origin[3]) //Check if a player is close to an origin
{
	//Get the players origin
	new player_origin[3]
	get_user_origin(index,player_origin)
	
	
	//See if its anywhere (horizonal and vertical) near the second origin parameter
	new bool:bNear=true,i=0
	while (bNear && i<3)
	{
		if (!( (player_origin[i]>=origin[i]-NEAR) && (player_origin[i]<=origin[i]+NEAR) ))
			bNear=false
		i++
	}
	return bNear
}
stock float_origin(origin[3],float:float_origin[3]) //Turn a integer origin into a float origin
{
	//Turn the numbers into floats
	for (new i=0;i<3;i++)
		float_origin[i]=float(origin[i])
}

public show_start_text() //Used to show a message on the first round
{
	showhudtoall(g_first_round_text)
}

public typeof(wp) //Returns the weapon type of the weapon id recieved
{
	
	switch (wp)
	{
		//If it's a primary weapon
		case CSW_SCOUT,CSW_XM1014,CSW_MAC10,CSW_AUG,CSW_UMP45,CSW_SG550,CSW_GALIL,CSW_FAMAS,CSW_AWP,CSW_MP5NAVY,CSW_M249,CSW_M3,CSW_M4A1,CSW_TMP,CSW_G3SG1,CSW_SG552,CSW_AK47,CSW_P90:
		{
			return W_PRIMARY
		}
		//If it's a secondery weapon
		case CSW_P228,CSW_ELITE,CSW_FIVESEVEN,CSW_USP,CSW_GLOCK18,CSW_DEAGLE:
		{  
			return W_SECONDARY
		}
		//If it's a knife
		case CSW_KNIFE:
		{
			return W_KNIFE
		}
		//If it's a granade
		case CSW_HEGRENADE,CSW_SMOKEGRENADE,CSW_FLASHBANG:
		{
			return W_GRENADE
		}
		//If it's a bomb
		case CSW_C4:
		{
			return W_BOMB
		}
		//If it's none of the item's above
		default:
		{
			return W_NONE
		}
	}
	return OK
}
public bool:data_exists(index) //Return a boolean which determines if the data index exists or not
{
	//If it's not empty
	return ( !(g_items[index][WEAPON]==EMPTY)&&!(g_items[index][WEAPON]==0) )
}
public data_insert(weapon,team,ammo) //Inserts data into the global items array
{
	//Creates a new item id
	new id=data_nextindex()
	
	//Stores the parameters in the global item's array with the index created before
	g_items[id][WEAPON]=weapon
	g_items[id][TEAM]=team
	g_items[id][AMMO]=ammo
	
	//Returns the id created
	return id
}
public data_nextindex() //Returns the next free index
{
	//Variables...
	new i=0,j=-1,bool:bDone=false
	//Loop through every item
	while ( (i<g_index)&&!(bDone) )
	{
		//And check if it's free
		if ( !(data_exists(i)) )
		{
			bDone=true
			j=i
		}
		i++
	}
	if (bDone)
		//If we have found a free cell then return it's id
		return j
	else
	{
		//Else expand the gloabl item's array and return the last cell
		g_index++
		return g_index-1
	}
	
	//Exit
	return OK
}
public data_remove(index) //Removes a data index
{
	//Change it's mode to "EMPTY" mode
	g_items[index][WEAPON]=EMPTY
}
public data_save() //Saves weapons the data to a file
{
	//Delete the old file if it exists
	if ( (file_exists(FILE)) )
		delete_file(FILE)
		
	
	//Text stores the text that will be save to the file and team is a temporary variable to store each item's team. weapon is just like team.
	new text[3200],team,weapon,ammo
	for (new i=0;i<g_index;i++)
	{
		if ( data_exists(i) )
		{
			//Store the item's team
			team=g_items[i][TEAM]
			
			//Store the item's weapon id
			weapon=g_items[i][WEAPON]
			
			//Store the item's ammo
			ammo=g_items[i][AMMO]
			
			
			//Add it to the text
			format(text,3200,"%s^n%i;%i;%i",text,team,weapon,ammo)
		}
	}
	
	
	//Now actually save it to the file
	write_file(FILE,text)
	
	//And exit
	return OK
}
public data_load() //Load the weapons data from a file
{
	//If the file does not exists do not continue
	if (!(file_exists(FILE)))
		return
	
	//Variables ...
	new line=0, text[64], txtlen,data[3][7],team,weapon,ammo
	
	//Loop and read every line of the file
	while ((line=read_file(FILE,line,text,63,txtlen)))
		if ( (!equali(text,";",1))&&(strlen(text)>2) ) // if it's not a comment and it's not empty
		{
			//Split the line into 2 parts (for example:"1;2", part one is "1" and part 2 is "2")
			ExplodeString(data,3,6,text,';')
			
			//Turn the data collected into numbers
			team=str_to_num(data[0])
			weapon=str_to_num(data[1])
			ammo=str_to_num(data[2])
			
			
			//Insert the data into the global items array
			data_insert(weapon,team,ammo)
		}
}
public event_roundend() //Fired every round end
{
	//Save all the items into a file if the saving is enabled
	if ( (get_cvar_num("ws_save")) )
		data_save()
		
	//Reset the players withdraws per round
	for (new i=0;i<33;i++)
		g_draws[i]=0
}
public menu_build(id) //Builds the basic menu (Deposit/Withdraw)
{
	//Check if the player is banned
	new key[64],steamid[64]
	get_user_authid(id,steamid,63)
	format(key,63,"WS_ban_%s",steamid)
	
	if ( (vaultdata_exists(key)) )
	{
		showhud(id,"[WS] Nie masz dostepu do przechowywania broni w skrzynkach")
		
		return OK
	}
	
	//Destroy the old menu
	if (g_menu[id])
		menu_destroy(g_menu[id])
		
	//Create the menu and give it a title
	g_menu[id]=menu_create("Co chcesz zrobic?","menu_do")
	
	
	//Create the options
	menu_additem(g_menu[id],"Zostaw bron w skrzynce","1")
	
	//Format the option's text
	new text[64]
	format(text,63,"Withdraw a weapon (%i/%i)",data_count(id),get_cvar_num("ws_maxitems"))
	menu_additem(g_menu[id],text,"2")
	
	//And show the menu to the user
	menu_display(id,g_menu[id],0)
	
	//Exit
	return OK
}
public data_count(id)  //Gets the number of items which exist and belong to the id parameter's team
{
	//Declare some variables...
	new i,counter,team=get_user_team(id)

	//Loop through the items global array
	for (i=0;i<g_index;i++)
		//If this cell is not empty then add 1 to the counter
		if ( (data_exists(i))&&(team==g_items[i][TEAM]) )
			counter++
			
	//Return our non empty cells counter
	return counter
}
public data_count_team(id)  //Gets the number of items which exist and belong to the id parameter's team
{
	//Declare some variables...
	new i,counter,team=id
		
	//Loop through the items global array
	for (i=0;i<g_index;i++)
		//If this cell is not empty then add 1 to the counter
		if ( (data_exists(i))&&(team==g_items[i][TEAM]) )
			counter++
			
	//Return our non empty cells counter
	return counter
}
public menu_do(id, menu, item) //The basic menu's handler
{
	new team=get_user_team(id)
	
	//If he is using the box but he is not near it
	if( !(player_near(id,g_origin[(team==2)?0:1]))&&(get_cvar_num("ws_teamlimited")) )
		//Cancel his menu
		return OK
		
	else if ( (!(player_near(id,g_origin[0]))&&!(player_near(id,g_origin[1])))&&(!get_cvar_num("ws_teamlimited")) )
		//Cancel his menu
		return OK
		
	
	//If it is "Wyjdz" we won't handle it
	if( item < 0 ) return OK
	
	
	//Get item info
	new cmd[3]
	new access, callback
 
	menu_item_getinfo(menu, item, access, cmd,2,_,_, callback)
	
	//Turn the result into a number
	new iChoice = str_to_num(cmd)
	
	switch (iChoice)
	{
		case 1: //He wants to deposit his current weapon
		{
			//Check if the weapon's type it legal
			
			
			new crap,type=typeof(get_user_weapon(id,crap,crap))
			
			if ( (type==W_BOMB)||(type==W_GRENADE)||(type==W_KNIFE)||(type==W_NONE)||(cs_get_user_shield(id)) )
			{
				//Tell the user that his weapon is not allowed
				showhud(id,"[WS] That kind of weapon is not allowed to be stored.")
				
				//Exit
				return OK
			}
			
			//Check if where is any spare room for items
			if ( (get_cvar_num("ws_maxitems"))<=data_count(id) )
			{
				//Tell the user that there is no room
				showhud(id,"[WS] The storage crate is full.")
				
				//Exit
				return OK
			}
			
			
			//Get his weapon's id and his team and the weapon's ammo
			new wp=get_user_weapon(id,crap,crap),team=get_user_team(id),ammo
			get_user_ammo(id,wp,ammo,crap)
			
			
			//Insert his weapon into the database
			data_insert(wp,team,ammo)
		
			//And strip his weapon
			fm_strip_user_gun(id)
			
			//Play a sound
			play_sound(id,1)
			
			//Show him a message
			//showhud(id,"[WS]Thanks! Your weapon is now stored.")
		}
		case 2: //He wants to withdraw a weapon
		{
			g_draws[id]++
			//Check if he is allowed to withdraw
			if ( (get_cvar_num("ws_limituse"))&&(g_draws[id]>get_cvar_num("ws_limituse")) )
			{
				//Inform the user about it
				showhud(id,"[WS] You have reached the maximun withdraws per round")
				
				//Decreas the player's withdraws per round because he didn't withdraw this time
				g_draws[id]--
				
				
				//Cya
				return OK
			}

			//If ws_random is enabled then pick a random weapon for him
			if ( (get_cvar_num("ws_random")) )
			{
				//Check if the crate is empty
				if ( !(data_count(id)) )
				{
					//Tell the player
					showhud(id,"[WS] The storage crate is empty")
					
					//Bye bye
					return OK
				}
				
				//Loop through all the items
				new count=0,items[ITEMS]
				for (new i=0;i<g_index;i++)
					//If it belongs to his team and he doesn't have another weapon from the same type
					if ( (data_exists(i))&&!(got_same_type(id,g_items[i][WEAPON]))&&(g_items[i][TEAM]==team) )
					{
						items[count]=i
						count++
					}
				
				if (count==0)
				{
					//It meens that the user has the same type of weapon
					showhud(id,"[WS] You already got another weapon of the same type")
					
					//Exit
					return OK
				}
				
				//Now pick a random weapon
				new rand=random_num(0,count-1)
				
				
				//Get the weapon's id
				new w_id=g_items[items[rand]][WEAPON]
				
				//Get the weapon's name
				new w_name[34]
				get_weaponname(w_id,w_name,33)
				
				//Give the weapon to the user
				give_item(id,w_name)
				
				//Change the weapon's ammo
				set_user_weapon_clip(id,w_id,g_items[items[rand]][AMMO])
				
				//Delete the item form the database
				data_remove(items[rand])
				
				//Play a sound
				play_sound(id,2)
			}
					
			else
				//Show him the withdraw menu
				menu_withdraw_build(id)
			
		}
	}
	
	
	//Exit
	return OK
}
stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") //Taken from the FM_UTIL because I'm not sure that every server has it
{
	new ent_class[32]
	if (!wid && wname[0])
		copy(ent_class, sizeof ent_class - 1, wname)
	else {
		new weapon = wid, clip, ammo
		if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
			return false
		
		get_weaponname(weapon, ent_class, sizeof ent_class - 1)
	}

	new ent_weap = fm_find_ent_by_owner(-1, ent_class, index)
	if (!ent_weap)
		return false

	engclient_cmd(index, "drop", ent_class)

	new ent_box = pev(ent_weap, pev_owner)
	if (!ent_box || ent_box == index)
		return false

	dllfunc(DLLFunc_Think, ent_box)

	return true
}



stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) //Taken from the FM_UTIL because I'm not sure that every server has it
{
	new strtype[11] = "classname", ent = index
	switch (jghgtype) {
		case 1: strtype = "target"
		case 2: strtype = "targetname"
	}

	while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}

	return ent
}

public menu_withdraw_build(id) //Builds the withdraw weapons menu
{
	//Destroy the old menu
	if (g_menu[id])
		menu_destroy(g_menu[id])
	
	//Create the menu and give it a title
	g_menu[id]=menu_create("Weapon withdraw","menu_withdraw_do")
	
	//Create the options
	new team=get_user_team(id),i,w_id,option[64],w_id_string[7],w_ammo,w_bullets[34]
	
	//Loop through all of the items
	while (i<g_index)
	{
		//If the cell is not empty and it belongs to the user's team
		if ( (data_exists(i))&&(g_items[i][TEAM]==team) )
		{
			//Store the weapon's id
			w_id=g_items[i][WEAPON]
			
			//Store the weapon's ammo
			w_ammo=g_items[i][AMMO]
			
			//Format the option's text and value
			format(w_bullets,63,"%i Bullets",w_ammo)
			
			format(option,63,"%s (%s)",W_NAMES[w_id],(w_ammo==0)?"Empty":w_bullets)
			
			num_to_str(i,w_id_string,6)
			
			
			//Add the option
			menu_additem(g_menu[id],option,w_id_string)
		}
		i++
	}
	
	//And show the menu to the user
	menu_display(id,g_menu[id],0)
	
	//Exit
	return OK
}
public menu_withdraw_do(id, menu, item) //The withdraw menu's handler
{
	new team=get_user_team(id)
	
	//If he is using the box but he is not near it
	if( !(player_near(id,g_origin[(team==2)?0:1]))&&(get_cvar_num("ws_teamlimited")) )
		//Cancel his menu
		return OK
		
	else if ( (!(player_near(id,g_origin[0]))&&!(player_near(id,g_origin[1])))&&(!get_cvar_num("ws_teamlimited")) )
		//Cancel his menu
		return OK
	
	
	//If it is "Exit" we won't handle it
	if( item < 0 ) return OK
	
	
	//Get item info
	new cmd[3]
	new access, callback
 
	menu_item_getinfo(menu, item, access, cmd,2,_,_, callback)
	
	//Turn the result into a number
	new iChoice = str_to_num(cmd)
	
	//Check if the item chosen was not already taken by another player
	if ( !(data_exists(iChoice)) )
	{
		//Decreas the player's withdraws per round because he didn't withdraw this time
		g_draws[id]--
		return OK
	}
		
	//Get the weapon's id
	new w_id=g_items[iChoice][WEAPON]
	
	
	//Check if he already got another weapon from the same type
	if ( (got_same_type(id,w_id)) )
	{
		//Decreas the player's withdraws per round because he didn't withdraw this time
		g_draws[id]--
		
		//Tell him about it
		showhud(id,"[WS] Już dostales inna bron tego samego typu")
		
		//And CYA soon
		return OK
	}
	
	
	//Get the weapon's name
	new w_name[34]
	get_weaponname(w_id,w_name,33)
	
	//Give the weapon to the user
	give_item(id,w_name)
	
	//Change the weapon's ammo
	set_user_weapon_clip(id,w_id,g_items[iChoice][AMMO])
	
	//Delete the item form the database
	data_remove(iChoice)
	
	//Play a sound
	play_sound(id,2)
	
	
	//Show a message to the user
	//showhud(id,"[WS]Enjoy!")
	
	
	//Exit
	return OK
}
public bool:got_same_type(index,weapon_id) //Checks if the player got another weapon from the same weapon id received
{
	//Get the weapon's type
	new type=typeof(weapon_id)
	
	
	//Get his weapons
	new i=0,j,w[32],bool:bFound=false
	
	get_user_weapons(index,w,j)
	
	
	//Loop trough his weapons
	while ( (i<j)&&(!bFound) )
	{
		//And check if they got the same weapon type
		if ( (type==typeof(w[i])) )
			bFound=true
		i++
	}
	return bFound
}
public set_user_weapon_clip(index,weapon,clip) //Set's the user's ammo in his clip
{
	new entity_index = fm_get_user_weapon_entity(index, weapon)
	cs_set_weapon_ammo (entity_index, clip)
}
stock fm_get_user_weapon_entity(id, wid = 0) //Taken from the FM_UTIL because I'm not sure that every server has it
{
	new weap = wid, clip, ammo
	if (!weap && !(weap = get_user_weapon(id, clip, ammo)))
		return 0
	
	new class[32]
	get_weaponname(weap, class, sizeof class - 1)

	return fm_find_ent_by_owner(-1, class, id)
}
public event_maxitems(num) //Checks if the "ws_maxitems" cvar is bigger then the weapons count on each team and if it does he removes some weapons
{
	//Check if the teams have more items then the maximun and if they do, delete the overfloating items
	new j,total
	
	for (new i=1;i<3;i++)
	{
		//Get the total items
		total=data_count_team(i)
		
		//If the total is smaller them the maximum
		if (total>num)
		{
			j=g_index
			
			while ( data_count_team(i)>num )
			{
				//If it's not empty and it belongs to the team
				if ( (data_exists(j))&&(g_items[j][TEAM]==i) )
					//Then remove it
					data_remove(j)
					
				j--
					
			}
		}
	}
	
	//Exit
	return OK
}
public play_sound(id,mod) //Plays the depositing/withdrawing sound
{
	//Choose the sound
	new sound[34]
	if (mod==1)
		sound=g_WEAPON_SOUND_D
	else
		sound=g_WEAPON_SOUND_W
	
	//Play the sound
	emit_sound(id, CHAN_ITEM, sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
public path_init()
{
	//Get the basedir
	new base[34]
	get_basedir(base,33)
	
	//Now add the basedir to the global file variables
	format(FILE,63,"%s%s",base,FILE)
	
	format(DEFAULT,63,"%s%s",base,DEFAULT)
}
public cmd_ban(id)
{
	//See if the admin send the player's name argument
	if ( (read_argc()==1) )
	{
		client_print(id,print_console,"[WS] Potrzebujesz wyslac imie gracza rowniez.^ neg:^" abcde ws_unban^"")
		return OK
	}
	
	//Get the player's name and id
	new player[64]
	read_argv(1,player,63)
	new playerid=get_user_index(player)
	
	//See if the player was found
	if ( !(playerid) )
	{
		client_print(id,print_console,"[WS] Gracz ^"% s ^" nie zostal znaleziony (to jest z rozroznianiem wielkosci liter)",player)
		return OK
	}
	
	//Get the player's steam id
	new steamid[64]
	get_user_authid(playerid,steamid,63)
	
	//Add it to the banned list
	new key[64]
	format(key,63,"WS_ban_%s",steamid)
	
	set_vaultdata(key,"1")
	
	//Inform the admin
	client_print(id,print_console,"[WS] %s nie masz dostepu do przechowywania broni w skrzyniach",player)
	
	return PLUGIN_HANDLED
}
public cmd_unban(id)
{
	//See if the admin send the player's name argument
	if ( (read_argc()==1) )
	{
		client_print(id,print_console,"[WS] Potrzebujesz wyslac imie gracza rowniez.^ neg:^" abcde ws_unban^"")
		return OK
	}
	
	//Get the player's name and id
	new player[64]
	read_argv(1,player,63)
	new playerid=get_user_index(player)
	
	//See if the player was found
	if ( !(playerid) )
	{
		client_print(id,print_console,"[WS] Gracz ^"% s ^" nie zostal znaleziony (to jest z rozroznianiem wielkości liter)",player)
		return OK
	}
	
	
	//Get the player's steam id
	new steamid[64]
	get_user_authid(playerid,steamid,63)
	
	//Remove it from the banned list
	new key[64]
	format(key,63,"WS_ban_%s",steamid)
	
	remove_vaultdata(key)
	
	//Inform the admin
	client_print(id,print_console,"[WS] %s masz teraz dostep do przechowywania broni w skrzyniach",player)
	
	return PLUGIN_HANDLED
}

Błedy:

/home/groups/amxmodx/tmp3/phpSstUx2.sma(203) : error 027: invalid character constant
/home/groups/amxmodx/tmp3/phpSstUx2.sma(203) : error 027: invalid character constant
/home/groups/amxmodx/tmp3/phpSstUx2.sma(246) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpSstUx2.sma(253) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpSstUx2.sma(253) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpSstUx2.sma(450) : error 037: invalid string (possibly non-terminated string)
/home/groups/amxmodx/tmp3/phpSstUx2.sma(451) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpSstUx2.sma(451) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpSstUx2.sma(451 -- 454) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpSstUx2.sma(454) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpSstUx2.sma(505 -- 506) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpSstUx2.sma(1155) : error 027: invalid character constant
/home/groups/amxmodx/tmp3/phpSstUx2.sma(1155) : error 027: invalid character constant
/home/groups/amxmodx/tmp3/phpSstUx2.sma(1191) : error 027: invalid character constant
/home/groups/amxmodx/tmp3/phpSstUx2.sma(1191) : error 027: invalid character constant

8 Errors.
Could not locate output file /home/groups/amxmodx/public_html/websc3/phpSstUx2.amx (compile failed).



proszę tylko o to wiecej nic nie będę chcial :D Ucze sie na bledach :P
  • +
  • -
  • 0




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

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