AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   custom functions (https://forums.alliedmods.net/showthread.php?t=318224)

LearninG 08-20-2019 14:17

custom functions
 
Hi,
I almost every time create custom functions in two ways :
1- function()
2- function(id)
Basically I don't know what to add in "()" I would be thankful if someone tell me some examples of custom functions with different "()"
and explain me what does "()" do exactly in functions.
Thanks.

edon1337 08-20-2019 14:23

Re: custom functions
 
There's no 'two ways', there's just different parameters. You add in () what you pass when calling it.

LearninG 08-20-2019 14:38

Re: custom functions
 
Quote:

Originally Posted by edon1337 (Post 2663991)
There's no 'two ways', there's just different parameters. You add in () what you pass when calling it.

I know , but that's how i create custom functions.

what type of values can i add into "()" , and how to use them in function ?

does this example works ?
PHP Code:

public some_func(variable1 variable2)
{
    
variable1 random_num(5,15)
    
variable2 variable1 10
    
    
if (variable1 10)
    {
        return 
variable2
    
}



thEsp 08-20-2019 14:45

Re: custom functions
 
Any kind. But I suggest you to read this wiki first.

edon1337 08-20-2019 14:46

Re: custom functions
 
Quote:

Originally Posted by LearninG (Post 2663994)
what type of values can i add into "()"

Any.

Quote:

Originally Posted by LearninG (Post 2663994)
how to use them in function ?

The way it's meant to be used.

Quote:

Originally Posted by LearninG (Post 2663994)
does this example works ?
PHP Code:

public some_func(variable1 variable2)
{
    
variable1 random_num(5,15)
    
variable2 variable1 10
    
    
if (variable1 10)
    {
        return 
variable2
    
}



If you mean compile, then it should, but I don't know what way you're expecting it to work, it takes 2 values, then assigns a random number in-between 5 and 15 to the first variable, then increases then second variable by 10, then it checks whether variable1 (the random number) is smaller than 10 and returns variable 2 if true.

LearninG 08-20-2019 15:05

Re: custom functions
 
thanks , now i will personally do some tests to experience of how it works.


All times are GMT -4. The time now is 17:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.