how to call a value from another function?
for exmple i have test()
and i wanna call from it a value 'slot' for example is it possible?
Printable View
how to call a value from another function?
for exmple i have test()
and i wanna call from it a value 'slot' for example is it possible?
Not sure what you mean with your question. Here's a few examples:
PHP Code:
foo()
{
a = bar();
iprintlnbold(a);
}
bar()
{
return "hello world";
}
PHP Code:
foo()
{
iprintlnbold(bar());
}
bar()
{
return "hello world";
}
PHP Code:
foo()
{
a = bar("world");
iprintlnbold(a);
}
bar(asdf)
{
return "hello " + asdf;
}
PHP Code:
foo()
{
iprintlnbold(bar("hello", "world"));
}
bar(asdf, jkl)
{
return asdf + " " + jkl;
}
All these functions result in an iprintlnbold("hello world");
test() call slot;
or did you mean:
PHP Code:
test()
{
// self is whatever the function called, for example player
if( isDefined( self ) )
{ /* do something */ }
}
player test();
i wanna call slot not the function the slot inside the function
Callback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime)
like if (swepon ==slot)
do some shit
test()
{
self endon("disconnect");
self notify("start_sprinting");
sprint_weap="iwx_sprint_mp";
slot="";
{
i still have no idea what you're trying to do. Explain better.
Use code tags.
Learn how to report on forums
Learn some english.
do you see the slot=""; inside the test funtion i wanna call it in another function
This visible within a given function
Use level or self or return;
return slot;
Code:test()
{
//... use if()
slot="kot";
//... use if()
slot="pog";
//... use if()
slot="";
//...
return slot;
}
Code:CodeCallback_PlayerCommand(args)
{
self endon("disconnect");
//...
if(args[0]=="test")
{
iprintlnbold(test());//output: kot |or| pog |or| "" - using if()
return;
}
//...
}
i dont mean this
i mean this
CodeCallback_PlayerCommand(args)
{
self endon("disconnect");
bingband=slot; /// how to call this slot from another function
}
test()
{
slot=3;/// i want to call the 3 to the other function how ?
}
CodeCallback_PlayerCommand(args)
{
self endon("disconnect");
bingband=test();
}
test()
{
slot=3;
return slot;
}
test()
{
bosswp(slot)=3; // i want the 3 go to the bosswp function how to write that? is my writing correct?
return slot;
}
bosswp(slot)
{
slotboss=slot;
return slot;
}
AHahAhahHaha
Omg, dude your very very stupid...
PHP Code:
your_stupid_function()
{
/* shit code */
/*...*/
return test();
}
test()
{
slot=3;
return slot;
}
thats not what i mean
test()=3 ; is it porssible
WHHHHAAAAAAAAAAAAAAAAAAT??????????????:DDDDDDDDDDD DDDDDDD
DUDE,MAYBE:
PHP Code:
your_function()
/*codeee*/
/*....*/
//argument - is = 3 or someone..
test(argument);
test(a) //a = argumet
{
/* EXAMPLE: */
iprintlnbold(a); //print center 3
iprintlnbold(15/int(a)); //print center 5
players=getentarray("player","classname");
iprintlnbold(players[int(a)].name); //print center client name by clientid = 3
}
what im trying to do is i want to remove this from dropping iwx_sprint_mp
and instead of that i want to drop the stored value that is stored in the sprint function
dropWeapon()
{
current = self getcurrentweapon();
if(current != "none")
{
weapon1 = self getweaponslotweapon("primary");
weapon2 = self getweaponslotweapon("primaryb");
if(current == weapon1)
currentslot = "primary";
else
{
assert(current == weapon2);
currentslot = "primaryb";
}
clipsize = self getweaponslotclipammo(currentslot);
reservesize = self getweaponslotammo(currentslot);
if(clipsize || reservesize)
self dropItem(current);
}
}
Sprint()
{
self endon("disconnect");
self notify("start_sprinting");
sprint_weap="iwx_sprint_mp";
slot="";
if(self getcurrentweapon()==self getweaponslotweapon("primary"))
slot="primary";
else
slot="primaryb";
self.sweapon=self getcurrentweapon();
if(self.sweapon==sprint_weap || self.sweapon=="none")
return;
what im trying to do is i want to remove this from dropping iwx_sprint_mp
and instead of that i want to drop the stored value that is stored in the sprint function
dropWeapon()
{
current = self getcurrentweapon();
if(current != "none")
{
weapon1 = self getweaponslotweapon("primary");
weapon2 = self getweaponslotweapon("primaryb");
if(current == weapon1)
currentslot = "primary";
else
{
assert(current == weapon2);
currentslot = "primaryb";
}
clipsize = self getweaponslotclipammo(currentslot);
reservesize = self getweaponslotammo(currentslot);
if(clipsize || reservesize)
self dropItem(current);
}
}
Sprint()
{
self endon("disconnect");
self notify("start_sprinting");
sprint_weap="iwx_sprint_mp";
slot="";
if(self getcurrentweapon()==self getweaponslotweapon("primary"))
slot="primary";
else
slot="primaryb";
self.sweapon=self getcurrentweapon();
if(self.sweapon==sprint_weap || self.sweapon=="none")
return;
No drop your sprint weapon:
PHP Code:
dropWeapon()
{
current = self getcurrentweapon();
if(current=="iwx_sprint_mp")
return;
if(current != "none")
{
weapon1 = self getweaponslotweapon("primary");
weapon2 = self getweaponslotweapon("primaryb");
if(current == weapon1)
currentslot = "primary";
else
{
assert(current == weapon2);
currentslot = "primaryb";
}
clipsize = self getweaponslotclipammo(currentslot);
reservesize = self getweaponslotammo(currentslot);
if(clipsize || reservesize)
self dropItem(current);
}
}
in the sprint function the real wepon stored in slot so i wanted like if current=="iwx_sprint_mp"
current==slot that stored in sprint how to call that?
I no understand your fucking stupid ENGLISH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Please read TUTORIALS, C,C#,C++, you dont have PROGRAMM BASE!!!
if(current=="iwx_sprint_mp")
current=slot; // the slot from the sprint function
Sprint()
{
self endon("disconnect");
self notify("start_sprinting");
sprint_weap="iwx_sprint_mp";
slot="";
if(self getcurrentweapon()==self getweaponslotweapon("primary"))
slot="primary";
else
slot="primaryb";
self.sweapon=self getcurrentweapon();
if(self.sweapon==sprint_weap || self.sweapon=="none")
return;
Code:if(current=="iwx_sprint_mp")
current=Sprint();
Sprint()
{
self endon("disconnect");
self notify("start_sprinting");
sprint_weap="iwx_sprint_mp";
slot="";
if(self getcurrentweapon()==self getweaponslotweapon("primary"))
slot="primary";
else
slot="primaryb";
self.sweapon=self getcurrentweapon();
return slot;
}
Sprint()
{
self endon("disconnect");
self notify("start_sprinting");
sprint_weap="iwx_sprint_mp";
slot="";
if(self getcurrentweapon()==self getweaponslotweapon("primary"))
slot="primary";
else
slot="primaryb";
self.sweapon=self getcurrentweapon();
if(self.sweapon==sprint_weap || self.sweapon=="none")
return;
self.sammo1=self getWeaponSlotAmmo(slot);
self.sammo2=self getWeaponSlotClipAmmo(slot);
self.is_Sprinting = true;
self setWeaponSlotWeapon(slot, sprint_weap);
sprint_ammo = int( (self.sprint_stamina / level.sprint_time) * 100 );
self setWeaponSlotAmmo(slot, sprint_ammo);
self switchToWeapon(sprint_weap);
wait 0.25;
maxwidth = 100;
while ( isAlive(self) && self useButtonPressed() && self.sprint_stamina > 0 && self getcurrentweapon()==sprint_weap)
{
wait 0.1;
if(!isMoving(self))
break;
self.sprint_stamina -= 25;
if(self.sprint_stamina < 0)
self.sprint_stamina = 0;
sprint_ammo = int( (self.sprint_stamina / level.sprint_time) * 100 );
self setWeaponSlotAmmo(slot, sprint_ammo);
}
if ( isAlive(self) && self.sweapon!="none" && (self getcurrentweapon()==sprint_weap || self getcurrentweapon()=="none"))
{
self setWeaponSlotWeapon(slot,self.sweapon);
self setWeaponSlotAmmo(slot,self.sammo1);
self setWeaponSlotClipAmmo(slot,self.sammo2);
self switchToWeapon(self.sweapon);
self.is_Sprinting = false;
}
if ( isAlive(self) && self.sweapon!="none" && self getcurrentweapon()!=sprint_weap && self getcurrentweapon()!="none")
{
self setWeaponSlotWeapon(slot,self.sweapon);
self setWeaponSlotAmmo(slot,self.sammo1);
self setWeaponSlotClipAmmo(slot,self.sammo2);
self.is_Sprinting = false;
}
}
thats the sprint function
what's problems?
Stop posting code without code tags.
if(current=="iwx_sprint_mp")
current=slot;/// how to bring the slot value from inside the function sprint to add it to the dropwepon function
use continue;
inside the function to the following condition