AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting a string for each client (https://forums.alliedmods.net/showthread.php?t=278615)

KiLLeR. 02-04-2016 11:36

Setting a string for each client
 
Is this the correct way to make a string for each client. Sorry, if the question sound a little stupid
PHP Code:

new btime[33][64], breason[33][64];

public 
client_putinserver(id)
{
    
formatex(btime[id], charsmax(btime[]), "1440");
    
formatex(breason[id], charsmax(breason[]), "hack");



klippy 02-04-2016 11:47

Re: Setting a string for each client
 
That looks okay. What exactly are you trying to accomplish?

KiLLeR. 02-04-2016 12:10

Re: Setting a string for each client
 
I made a custom ban menu, where the admins can change the time and reason from the options, but I need to set a something by default. By the way, thanks for the reply.

Sorry for my English!

Bugsy 02-04-2016 20:42

Re: Setting a string for each client
 
formatex() should only be used when you are actually FORMATTING the string. In your example, you are only copying a string to a string variable so you should use copy() instead.

copy() takes the same parameters and in the same order as formatex():
PHP Code:

new btime[33][64], breason[33][64];

public 
client_putinserver(id)
{
    
copy(btime[id], charsmax(btime[]), "1440");
    
copy(breason[id], charsmax(breason[]), "hack");
}  

//This is an example of when formatex() should be used:
public client_putinserver(id)
{
    
formatex(btime[id], charsmax(btime[]), "hello %s it is %d oclock" "bugsy" 10 );
    
formatex(breason[id], charsmax(breason[]), "hack %s" "stuff" );



siriusmd99 02-07-2016 10:52

Re: Setting a string for each client
 
hahaha. lol. why u are setting the same strung for all players, just make a cvar for default time and reason and then set task for cvar parse or use get_pcvar_string on ban and done.

Bugsy 02-07-2016 11:45

Re: Setting a string for each client
 
Quote:

Originally Posted by siriusmd99 (Post 2390808)
hahaha. lol. why u are setting the same strung for all players, just make a cvar for default time and reason and then set task for cvar parse or use get_pcvar_string on ban and done.

"hahaha" "lol" ? What is so funny about his question?

I don't think someone can tell exactly what he is doing based on what he posted. Many times people post snippets like that when they are trying to figure something out.

siriusmd99 02-07-2016 12:03

Re: Setting a string for each client
 
Quote:

Originally Posted by Bugsy (Post 2390834)
"hahaha" "lol" ? What is so funny about his question?

I don't think someone can tell exactly what he is doing based on what he posted. Many times people post snippets like that when they are trying to figure something out.

That's why I laughed , I tried to make him pay attention to what he said maybe he is trying to do something else, but there is no sense to add the same string to every player. He can add 2 string constants at the top of the plugin or cvars.

By the way, can you look on my recent topic I have also a funny question? I can't solve it, thanks.

Bugsy 02-07-2016 12:19

Re: Setting a string for each client
 
I don't get it, but ok.

KiLLeR. 02-07-2016 15:57

Re: Setting a string for each client
 
Quote:

Originally Posted by Bugsy (Post 2390180)
formatex() should only be used when you are actually FORMATTING the string. In your example, you are only copying a string to a string variable so you should use copy() instead.

copy() takes the same parameters and in the same order as formatex():
PHP Code:

new btime[33][64], breason[33][64];

public 
client_putinserver(id)
{
    
copy(btime[id], charsmax(btime[]), "1440");
    
copy(breason[id], charsmax(breason[]), "hack");
}  

//This is an example of when formatex() should be used:
public client_putinserver(id)
{
    
formatex(btime[id], charsmax(btime[]), "hello %s it is %d oclock" "bugsy" 10 );
    
formatex(breason[id], charsmax(breason[]), "hack %s" "stuff" );



Thanks for your correction. That's the right thing that I wanted to hear. It crossed my mind to use 'copy(...)', just I wasn't sure and decided to ask. The thing what I trying to do is already done and works.

P.S. @siriusmd99: The btime holds a time for bans, where each admin can change it as he decide. So if I use CVARs, if one admin change the time, it will be changed for all admins. Same for breason!

siriusmd99 02-07-2016 16:23

Re: Setting a string for each client
 
aha, i thought it was bantime for players.my wrong, sorry.


All times are GMT -4. The time now is 09:24.

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