hello, help with quick strings. -
danish007 - 30.12.2014
hello,
i want to make quickstrings like $cash to show players cash in chat.
i want to make like
if i write "i have $cash" i changes into "i have $50000" or if i type "/pm 0 i've $cash" it changes into "/pm o i've $50000"
please help me
AW: hello, help with quick strings. -
CutX - 30.12.2014
format
Quote:
|
Originally Posted by wikisamp
Formats a string to include variables and other strings inside it.
|
just what you wanted
Re: hello, help with quick strings. -
Facerafter - 30.12.2014
Not sure about commands but for the normal chat
You can detect with $cash with strfind and I believe someone made a str_replace. (Not sure if this
one works)
And put them under OnPlayerText
Re: hello, help with quick strings. -
BroZeus - 30.12.2014
Get strlib from here
https://sampforum.blast.hk/showthread.php?tid=85697
then use like this
pawn Код:
public OnPlayerText(playerid, text[])
{
if(strfind(text, "$cash"))
{
new str[100];
format(str, sizeof(str), "{ff0000}%s:{ffffff} %s", GetName(playerid), strreplace("$cash", GetPlayerMoney(playerid), text));
SendClientMessageToAll(-1, str);
return 0;
}
return 1;
}
Re: hello, help with quick strings. -
danish007 - 30.12.2014
its only works when i type only $cash but not works when i type this like "hey i got $cash"
Re: hello, help with quick strings. -
BroZeus - 30.12.2014
hmm try this one
pawn Код:
public OnPlayerText(playerid, text[])
{
if(strfind(text, "$cash") >= 0)
{
new str[100];
format(str, sizeof(str), "{ff0000}%s:{ffffff} %s", GetName(playerid), strreplace("$cash", GetPlayerMoney(playerid), text));
SendClientMessageToAll(-1, str);
return 0;
}
return 1;
}
Re: hello, help with quick strings. -
danish007 - 30.12.2014
its giving me undefined symbol strreplace
Re: hello, help with quick strings. -
BroZeus - 30.12.2014
get strlib from here
https://sampforum.blast.hk/showthread.php?tid=85697
Oh and it is str_replace not strreplace my mistake
Just change strreplace to str_replace in code i gave
Re: hello, help with quick strings. -
leo9 - 30.12.2014
try this
Код:
if(strfind(text, "$cash"))
{
str_replace("$cash", GetPlayerMoney(playerid), text));
}
Re: hello, help with quick strings. -
danish007 - 30.12.2014
Quote:
Originally Posted by leo9
try this
Код:
if(strfind(text, "$cash"))
{
str_replace("$cash", GetPlayerMoney(playerid), text));
}
|
used it
but got
Код:
F:\Cruel World Deathmatch\Deathmatch Server\gamemodes\DEATHMATCH.pwn(3834) : error 017: undefined symbol "str_replace"
F:\Cruel World Deathmatch\Deathmatch Server\gamemodes\DEATHMATCH.pwn(3834) : error 029: invalid expression, assumed zero
F:\Cruel World Deathmatch\Deathmatch Server\gamemodes\DEATHMATCH.pwn(3834) : warning 215: expression has no effect