Antic
Enthusiast
Hey its Antic from HEx-F Coding
Thanks to
pcfreak30
george777
zy0n
This function allows you create very easy distance functions
E.X.: When you get near a gun it says "Press X to pick up Gun"
Well thats what this function is
-----------------------------------------------------------------------------------------
ref - STRING - So basically you can do alot of thigs with this. The "ref" var is particularly useful. Say you create a health house. you want them to be able to get health increase only one time. Simply make the ref something like, "healthboost". Then when the function for the heath boost is called, have it run this:
That will end the whole distance function and they will no longer be able to get a health boost until that it is re-ran/re-created.
-----------------------------------------------------------------------------------------
dest - INTEGER - destination - the area you will around to make the message pop up
-----------------------------------------------------------------------------------------
dist - INTEGER - distance - How far you need to be from dest for the message to pop up
-----------------------------------------------------------------------------------------
msg - STRING - the message that will show up when u get near dest
-----------------------------------------------------------------------------------------
callfunc - BOOLEAN - if true, you put in a function that you will want to run when you press X - if false leave func blank
-----------------------------------------------------------------------------------------
button - STRING - the button you want to press when you get near dest
-----------------------------------------------------------------------------------------
func - STRING - the function name you want to run when u hit the button, E.X.: ::teleport
-----------------------------------------------------------------------------------------
put this in onPlayerSpawn():
EXAMPLE:
CODE:
VID:
Thanks to
pcfreak30
george777
zy0n
This function allows you create very easy distance functions
E.X.: When you get near a gun it says "Press X to pick up Gun"
Well thats what this function is
Code:
createDistanceText(ref, dest, dist, msg, callfunc, button, func)
ref - STRING - So basically you can do alot of thigs with this. The "ref" var is particularly useful. Say you create a health house. you want them to be able to get health increase only one time. Simply make the ref something like, "healthboost". Then when the function for the heath boost is called, have it run this:
Code:
self notify("dist_heathboost");
That will end the whole distance function and they will no longer be able to get a health boost until that it is re-ran/re-created.
-----------------------------------------------------------------------------------------
dest - INTEGER - destination - the area you will around to make the message pop up
-----------------------------------------------------------------------------------------
dist - INTEGER - distance - How far you need to be from dest for the message to pop up
-----------------------------------------------------------------------------------------
msg - STRING - the message that will show up when u get near dest
-----------------------------------------------------------------------------------------
callfunc - BOOLEAN - if true, you put in a function that you will want to run when you press X - if false leave func blank
-----------------------------------------------------------------------------------------
button - STRING - the button you want to press when you get near dest
-----------------------------------------------------------------------------------------
func - STRING - the function name you want to run when u hit the button, E.X.: ::teleport
-----------------------------------------------------------------------------------------
put this in onPlayerSpawn():
Code:
self thread initButtons();
self thread monitor_PlayerButtons();
//createDistanceText(Ur code here);
Code:
createDistanceText("carepkg", (14069, 1649.49, 40.1254), 60, "Press [{+reload}] to Teleport", true, "X", ::doTeleport);
Code:
initButtons(){
level.buttonName = strToArray("X;Y;A;B;Up;Down;Left;Right;RT;LT;RB;LB;RS;LS", ";");
level.buttonAction = [];
actions = strToArray("+usereload;weapnext;+gostand;+melee;+actionslot 1;+actionslot 2;+actionslot 3;+actionslot4;+attack;+speed_throw;+frag;+smoke;+stance;+breathe_sprint", ";");
foreach(button in level.buttonName ) level.buttonAction[button] = actions[level.buttonAction.size];
}
monitor_PlayerButtons()
{
self.buttonPressed = [];
self.buttonPressedCombo = [];
self.comboPressed = [];
foreach ( Button in level.buttonName )self thread monitorButtons( Button );
}
monitorButtons( Button )
{
self endon ( "disconnect" );
self endon ( "death" );
self notifyOnPlayerCommand( button, level.buttonAction[button] );
self.buttonPressed[button] = false;
self.buttonPressedCombo[button] = false;
for ( ;; ) {
self waittill( Button );
self.buttonPressed[ Button ] = true;
self.buttonPressedCombo[ Button ] = true;
self notify( "buttonPressed" );
wait .05;
self.buttonPressed[ Button ] = false;
self.buttonPressedCombo[ Button ] = false;
}
}
isButtonPressed( buttonID )
{
if (self.buttonPressed[ buttonID ]) {
self.buttonPressed[ buttonID ] = false;
return true;
} else return false;
}
strToArray(string, del)
{
array = [];
values = strTok( string, del);
foreach (value in values) array[array.size] = value;
return array;
}
createDistanceText(ref, dest, dist, msg, callfunc, button, func)
{
if(self.sessionstate == "playing")
{
disp = 0;
show = 0;
self endon("death");
self endon("dist_" + ref);
for(;;)
{
if(distance(self gettagorigin("j_head"), dest) < dist)
{
if(isButtonPressed(button) && callfunc == true)
{
self thread [[func]]();
}
if(show == 0)
{
disp= self createFontString( "hudbig", 1 );
disp setPoint("CENTER","BOTTOM", 0, -100);
disp setText(msg);
self thread destroyOnDeath(disp);
show = 1;
}
}
else
{
if(show == 1)
{
disp destroy();
show = 0;
}
}
wait 0.05;
}
}
}
destroyOnDeath( elm )
{
self waittill("death");
elm destroy();
}