AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Attaching a native to a variable (https://forums.alliedmods.net/showthread.php?t=127346)

bluechester 05-19-2010 22:23

Attaching a native to a variable
 
I am trying to attach this
PHP Code:

new iPlayer[32] = get_user_name(id); 

(line 153)

So then I can execute a command on a client
PHP Code:

client_cmd(id"zp_bazooka %s"iPlayer); 

But I get the following error
Code:

Error: Number of arguments does not match definition on line 153
Help please?

Kreation 05-19-2010 22:26

Re: Attaching a native to a variable
 
Why not just do this.

Code:
new iPlayer[32]; get_user_name( id, iPlayer, 31 ); client_cmd( id, "zp_bazooka %s", iPlayer );

bluechester 05-19-2010 22:29

Re: Attaching a native to a variable
 
Let me try, and thanks for the quick reply.

EDIT: works, thanks. Learned something new today :D

Kreation 05-19-2010 22:32

Re: Attaching a native to a variable
 
Anytime.

fysiks 05-19-2010 22:34

Re: Attaching a native to a variable
 
The name is a string so the variable should be labled as a string (sz) not an integer (i). Also, retrieving strings from natives you will always put the string variable and the max string length as arguments.

If I ever have a question like this I always go to the funcwiki first. For the majority of functions it shows what the arguments should be and in some cases shows an example usage of the function.

Kreation 05-19-2010 22:41

Re: Attaching a native to a variable
 
Is that directed toward me or him?

fysiks 05-20-2010 00:20

Re: Attaching a native to a variable
 
Quote:

Originally Posted by Kreation (Post 1185597)
Is that directed toward me or him?

Anybody really.


All times are GMT -4. The time now is 03:49.

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