i wrote something, hope4 it helps
Code:
/*=============================================
>>Qickmenu - Shop<<
call this on the gametypes start, where all other init's are located
you have to create a new menu in the menufiles (menu/scriptmenu) before
call the menu "shopmenu"
for every shopitem there have to be a scriptmenuresponse with: "shopitem_1","shopitem_2", and so on
dont forget to precache the menu
link: http://wiki.modsrepository.com/index.php/Call_of_Duty_5:_Menu_Modding_Basics
there might be some syntax errors, post on modsonline for help
hope it helps a little
xf: serthy
=============================================*/
init()
{
game["menu_shop"] = "shopmenu"; //declare the shopmenu
precacheMenu(game["menu_shop"]); //precache the shopmenu
precahceString( &"Money: " ); //for money hud (need to have a [&] before!
level OnPlayerConnecting();
}
OnPlayerConnecting() //everytime a player is connecting...
{
level endon( "intermission" );
for( ; ; )
{
level waittill( "connecting" , player );
if( isDefined( player ) && isPlayer( player ) )
player thread OnPlayerConnected();
}
}
OnPlayerConnected() //...run this on the player
{
self endon( "disconnect" );
wait 1;
self.pers["money"] = 0; // initialise his money on connecting to zero
self thread MoneyScreen(); //call the money hud
for( ; ; )
{
self waittill( "menuresponse" , menu , response ); // everytime there is a menuresponse ( ex: quickmenu )
if( menu != game["menu_shop"] ) //if the menu is our shop, else continue waiting
continue;
thread quickshop( response ); //start the shop function depending on the response
}
}
quickshop( response )
{
if( !isdefined( self.pers["team"] ) || self.pers["team"] == "spectator" || isdefined( self.spamdelay ) )
return; // if the player is not allowed to use the shop
self.spamdelay = true; //this stops the player abusing the shop
if( self.pers["team"] == "allies" ) //if the player is a hunter
{
switch( response )
{
case "shopitem_1": // shopitem_1 : you can call it whatever you want (depending on the scriptmenuresponse on menu-file
self thread hunter_mine(); // then thread that what you want to give the shopuser
break;
case "shopitem_2":
self thread hunter_healthpack();
break;
default:
break;
}
}
else if( self.pers["team"] == "axis" ) //same with zombies
{
switch( response )
{
case "shopitem_1":
self thread zombie_jump();
break;
case "shopitem_2":
self thread zombie_explode();
break;
default:
break;
}
}
//you need to continue this to have more items on your shop
}
hunter_mine() //example for one shopitem
{
if( !isDefined( self.pers["money"] || self.pers["team != "allies"] ) //if the user dont have money or is in the wron team, quit
return;
if( self.pers["money"] >= level.price["mine"] ) //if the user has enough money
{
self.pers["money"] -= level.price["mine"]; //sell the item
if( isDefined( self.mines ) ) //give the item
self.mines++;
else self.mines = 1;
self iprintlnBold( "^2You bought a mine ^1(-" + level.price["mine"] + ")" ); //say it to the user
}
else
{
self iprintlnBold( "^1You don't have enough Money to buy this!" ); //else he does not have enough money
}
}
hunter_healthpack()
{
//same with the other items
}
zombie_jump()
{
}
zombie_explode()
{
}
MoneyScreen()
{
self endon( "disconnect" );
self.hud_money = newHudElem( self );
self.hud_money.x = 500; // the x position on screen [ range 0 - 640 ]
self.hud_money.y = 300; // the y position on screen [ range 0 - 480 ]
self.hud_money.fontsize = 2; // the size of the text/number
self.hud_money.color = ( 0 , 1 , 0 ); // color in [ ( red , blue , green ) range 0 - 1 ]
self.hud_money.sort = 9998;
self.hud_money.alpha = 1; // visibility [ range 0 - 1 ]
self.hud_money.label = &"Money: "; // the text (must be precahced)
while( isDefined( self.hud_money ) )
{
wait 1;
self.hud_money setValue( self.pers["money"] ); // updates the money every second
}
}