AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Transfer data from functions? (https://forums.alliedmods.net/showthread.php?t=46069)

Drak 10-17-2006 20:42

Transfer data from functions?
 
How would i get the random data that was made in one function to another?
Code:
stock buying(id,pet[],cost) {     new ages = random_num(1,8)     new menu_body[256]     new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)     if(equali(pet,"dog"))     {         format(menu_body,256,"Pet is %s^n Age: %i",pet,ages)         show_menu(id,keys,menu_body)     } } public data_here(id) {             client_print(id,print_chat,"[TEST] %s",pet) }

So, how would i get the age/pet from 'buying' to a different function?

wonsae 10-17-2006 21:14

Re: Transfer data from functions?
 
Make pet a global function

Emp` 10-17-2006 21:46

Re: Transfer data from functions?
 
Quote:

Originally Posted by wonsae (Post 392349)
Make ages a global variable


Zenith77 10-17-2006 22:43

Re: Transfer data from functions?
 
Umm no, just change your function decleration:

Code:
public data_here(id, const pet[]) {             client_print(id,print_chat,"[TEST] %s",pet) } public some_test_func(id, const pet[]) {     // Call it     data_here(id, pet); }

wonsae 10-17-2006 23:30

Re: Transfer data from functions?
 
Eep, sorry, I was typing too fast :X


All times are GMT -4. The time now is 04:50.

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