Raised This Month: $ Target: $400
 0% 

%s dont work pls help im a noob in scripting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-06-2010 , 04:59   %s dont work pls help im a noob in scripting
Reply With Quote #1

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
mottzi is offline
Send a message via MSN to mottzi
reinert
Veteran Member
Join Date: Feb 2007
Old 06-06-2010 , 05:00   Re: %s dont work pls help im a noob in scripting
Reply With Quote #2

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);
reinert is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-06-2010 , 05:02   Re: %s dont work pls help im a noob in scripting
Reply With Quote #3

Quote:
Originally Posted by mottzi View Post
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?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-06-2010 , 06:18   Re: %s dont work pls help im a noob in scripting
Reply With Quote #4

Thanks, i try it now =)


First i show message then i redirect =)
mottzi is offline
Send a message via MSN to mottzi
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-06-2010 , 06:23   Re: %s dont work pls help im a noob in scripting
Reply With Quote #5

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
mottzi is offline
Send a message via MSN to mottzi
Oneshox
BANNED
Join Date: May 2010
Location: Germany
Old 06-06-2010 , 06:25   Re: %s dont work pls help im a noob in scripting
Reply With Quote #6

it can also be

szName[18]
get_user_name(id, szName, 17)
Oneshox is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-06-2010 , 07:03   Re: %s dont work pls help im a noob in scripting
Reply With Quote #7

could it also be 2 and 1?
mottzi is offline
Send a message via MSN to mottzi
Oneshox
BANNED
Join Date: May 2010
Location: Germany
Old 06-06-2010 , 08:09   Re: %s dont work pls help im a noob in scripting
Reply With Quote #8

i don't know i never tested it
Oneshox is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-06-2010 , 08:39   Re: %s dont work pls help im a noob in scripting
Reply With Quote #9

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.
__________________

Last edited by Bugsy; 06-06-2010 at 08:45.
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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