PDA

View Full Version : Spawn on map (Toujane)



Invictus
9th March 2013, 17:04
Hi there. I have a problem with spawn "teddy bear" Here is the code.


main()
{
teddy = getent("script_model");
teddy setHintString("Press F to buy teddy");
teddy = spawn("script_model", (174, -310, 16));
teddy.angles = (0, 57, 0);
teddy setmodel("xmodel/prop_bear_detail_sitting");
}


In menus.gsc I load the model teddy bear


precacheModel("xmodel/prop_bear_detail_sitting");

Teddy don't spawn. I don't now where is problem.

Invictus
9th March 2013, 17:19
Ok. Teddy Spawn :) But i don't see "Press F to buy teddy".

Earliboy
9th March 2013, 18:06
Add under the "precacheModel"

precacheString(&"Press F to buy teddy");

Then just add at the HintString

teddy setHintString(&"Press F to buy teddy");

Earliboy
9th March 2013, 18:07
You also can use [[{USE}]] (if i´m right, may it was {{[use]}} but i´m not sure, that will show the button where Use is bind on)

Ni3ls
9th March 2013, 18:16
You also can use [[{USE}]] (if i´m right, may it was {{[use]}} but i´m not sure, that will show the button where Use is bind on)

Yes u are right;) [[{+use}]] should do the job

kung foo man
9th March 2013, 18:30
setHintString() doesnt work on spawned entities. So you need to do it manual:



displayHintString(hintstring, entity)
{
player = self;

if ( ! isDefined(player))
return;

if ( ! isDefined(hintstring))
return;

if (isdefined(player.hintstring))
return;

player.hintstring = newClientHudElem(player);
player.hintstring.horzAlign = "fullscreen";
player.hintstring.vertAlign = "fullscreen";
player.hintstring.alignX = "center";
player.hintstring.alignY = "middle";
player.hintstring.x = 320; // 640
player.hintstring.y = 300; // 480
player.hintstring.fontScale = 1.6; // 1.1
player.hintstring.alpha = 1; // zero to one
player.hintstring setText(hintstring);

player thread deleteHintString(entity);
}

deleteHintString(entity)
{
player = self;

while (isdefined(player) && isdefined(player.hintstring))
{
if (player isTouching(entity.trigger))
{
wait 0.10;
continue;
}

player.hintstring destroy();
}
}

Invictus
9th March 2013, 19:35
Ok. I fix this. I add triger (radius) and string. All works. Thanks for help.