ok i managed to do it by myself!
void RemoveWhitespaceCallback(IConVar *var, const char *pOldValue, float
flOldValue)
{
ConVar *pVar = (ConVar*)var;
if(!pVar)
{
Warning("Cannot cast IConVar %s to ConVar\n", var->GetName());
return;
}
char pszNewValue[512];
memset(pszNewValue, 0, sizeof(pszNewValue));
const char *pszCurrentValue = pVar->GetString();
for(unsigned int i = 0; i < strlen(pszCurrentValue); ++i)
{
if(isspace(pszCurrentValue[i]))
{
//continue;
char c = '_';
Q_strncat(pszNewValue,&c, sizeof(pszNewValue), 1);
}
else
{
Q_strncat(pszNewValue, &pszCurrentValue[i], sizeof(pszNewValue),
1);
}
}
if(Q_stricmp(pszNewValue, pszCurrentValue))
pVar->SetValue(pszNewValue);
numero_demo = 1;
}
static ConVar hlds_patron("hlds_patron","patron", FCVAR_NONE, "patron para
las demos: hlds_<patron>_<numero>.dem", RemoveWhitespaceCallback);
thank you SO much for your patience, and thank you mr Saul :D
2009/12/9 Didrole <[email protected]>
> strtools.h
>
> char *V_strncat(char *, const char *, size_t destBufferSize, int
> max_chars_to_copy=COPY_ALL_CHARACTERS );
> [...]
> #define Q_strncat V_strncat
>
>
> So Q_strncat = V_strncat and V_strncat is the Valve's version of strncat
>
> 2009/12/9 JoeX <[email protected]>
>
> > aha!
> >
> > it just... strncat
> >
> > but.... a conceptual question..... why?.... qhy defineit with a Q_?.....
> >
> >
> > 2009/12/9 Didrole <[email protected]>
> >
> > > Q_strncat is nothing more than a classic strncat .
> > >
> > > Replacing whitespaces with underscores is a very easy operation, if you
> > are
> > > not able to do that yourself you should re-read some c/c++ lessons.
> > >
> > > 2009/12/9 JoeX <[email protected]>
> > >
> > > > wow!, it woks!....
> > > >
> > > > and..... i never have seen that Q_strncat method..... of function (:
> > > >
> > > > hot you edit that code to replace whitespaces with underscores? :D
> > > >
> > > > hey mister Saul, what is about your proyect?, can i see it working?
> :D
> > > >
> > > > 2009/12/9 Saul Rennison <[email protected]>
> > > >
> > > > > http://cpp.pastebin.com/f2a5306a8
> > > > >
> > > > > Thanks,
> > > > > - Saul.
> > > > >
> > > > >
> > > > > 2009/12/9 JoeX <[email protected]>
> > > > >
> > > > > > thank you David Kraeutmann and keeper!
> > > > > >
> > > > > > from you keeper, i read a lot before, just googling..... in this
> 3
> > > days
> > > > > of
> > > > > > workshop, u'r anwers helped me a lot, thank you
> > > > > >
> > > > > > i'll try to implement the callback, and wait the implementation
> of
> > > Mr.
> > > > > Saul
> > > > > > :D
> > > > > >
> > > > > > 2009/12/9 Keeper <[email protected]>
> > > > > >
> > > > > > > Look at the definition of ConVar ... one of them includes a
> > > function
> > > > > call
> > > > > > > back:
> > > > > > >
> > > > > > > void testentry ( IConVar *pVar, char const *pOldString, float
> > > > > pOldFloat)
> > > > > > {
> > > > > > > // do your entry examination here....
> > > > > > > }
> > > > > > >
> > > > > > > static ConVar empty_cvar("plugin_empty", "0", 0, "Example
> plugin
> > > > cvar",
> > > > > > > (FnChangeCallback_t)testentry);
> > > > > > >
> > > > > > > Keeper
> > > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: JoeX [mailto:[email protected]]
> > > > > > > Sent: Wednesday, December 09, 2009 2:06 PM
> > > > > > > To: Discussion of Half-Life Programming
> > > > > > > Subject: [hlcoders] how to use cvars? (removing whitespaces)
> > > > > > >
> > > > > > > first.... i want to thank AzuiSleet, Saul Rennison and Jacob
> > Heidt
> > > > for
> > > > > > > their
> > > > > > > support in the last topic about "tf2 client plugin question",
> > your
> > > > help
> > > > > > is
> > > > > > > much appreciated. Thank you again
> > > > > > >
> > > > > > > in documentation, i can't find how to run code, when the user
> > > change
> > > > > the
> > > > > > > value of a cvar...
> > > > > > >
> > > > > > > i got this....
> > > > > > >
> > > > > > > static ConVar empty_cvar("plugin_empty", "0", 0, "Example
> plugin
> > > > > cvar");
> > > > > > >
> > > > > > > i want to remove whitespaces from user...., that means:
> > > > > > >
> > > > > > > (console)
> > > > > > > ]plugin_empty hola amigos
> > > > > > > ]plugin_empty
> > > > > > > plugin_empty = "holaamigos" (def = "0")
> > > > > > > Example plugin cvar
> > > > > > >
> > > > > > > but..... how to make my own code, to "intercept" plugin_empty
> > > > > > mdifications?
> > > > > > > like CON_COMMAND, with a code block...
> > > > > > >
> > > > > > > cheers from Chile! (LA)
> > > > > > > _______________________________________________
> > > > > > > To unsubscribe, edit your list preferences, or view the list
> > > > archives,
> > > > > > > please visit:
> > > > > > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > To unsubscribe, edit your list preferences, or view the list
> > > > archives,
> > > > > > > please visit:
> > > > > > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > > > > >
> > > > > > >
> > > > > > _______________________________________________
> > > > > > To unsubscribe, edit your list preferences, or view the list
> > > archives,
> > > > > > please visit:
> > > > > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > > > >
> > > > > >
> > > > > _______________________________________________
> > > > > To unsubscribe, edit your list preferences, or view the list
> > archives,
> > > > > please visit:
> > > > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > > >
> > > > >
> > > > _______________________________________________
> > > > To unsubscribe, edit your list preferences, or view the list
> archives,
> > > > please visit:
> > > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > >
> > > >
> > > _______________________________________________
> > > To unsubscribe, edit your list preferences, or view the list archives,
> > > please visit:
> > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > >
> > >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders