AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   %s dont work pls help im a noob in scripting (https://forums.alliedmods.net/showthread.php?t=128845)

mottzi 06-06-2010 04:59

%s dont work pls help im a noob in scripting
 
Hello guys. Why doesnt this line work?

client_print(0, print_chat, "%s went to: Zombie Plague 1 [Day]. Say: /server to follow him.", get_player_name(id));

the line is in this public:

public menu_handler(id, menu, item) {}

can somebody help me pls

reinert 06-06-2010 05:00

Re: %s dont work pls help im a noob in scripting
 
new szName[33]
get_user_name(id, szName, 32)
client_print(0, print_chat, "%s went to: Zombie Plague 1 [Day]. Say: /server to follow him.", szName);

GXLZPGX 06-06-2010 05:02

Re: %s dont work pls help im a noob in scripting
 
Quote:

Originally Posted by mottzi (Post 1201095)
Hello guys. Why doesnt this line work?

client_print(0, print_chat, "%s went to: Zombie Plague 1 [Day]. Say: /server to follow him.", get_player_name(id));

the line is in this public:

public menu_handler(id, menu, item) {}

can somebody help me pls

Why is it in a menu handler? Are you creating a menu, and setting a case to send a player to another server, then displaying a message?

mottzi 06-06-2010 06:18

Re: %s dont work pls help im a noob in scripting
 
Thanks, i try it now =)


First i show message then i redirect =)

mottzi 06-06-2010 06:23

Re: %s dont work pls help im a noob in scripting
 
OK it worked but i dont understand why...

get_user_name saves the name into the varibale szName. but why 33 and 32 what are this nummbers standing for?

// SRY for the double posting

Oneshox 06-06-2010 06:25

Re: %s dont work pls help im a noob in scripting
 
it can also be

szName[18]
get_user_name(id, szName, 17)

mottzi 06-06-2010 07:03

Re: %s dont work pls help im a noob in scripting
 
could it also be 2 and 1? :|

Oneshox 06-06-2010 08:09

Re: %s dont work pls help im a noob in scripting
 
i don't know i never tested it

Bugsy 06-06-2010 08:39

Re: %s dont work pls help im a noob in scripting
 
Pawn uses null terminated strings which means you must always create your variable 1 size larger than the max you will need. This is why, for example, you will see a variable created at size 32 but the size inputted to the function is 31. The extra cell is reserved for a null character which signifies the end of string. Google null terminated strings for further reading.


All times are GMT -4. The time now is 05:27.

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