hello, help with quick strings.
#1

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
Reply
#2

format

Quote:
Originally Posted by wikisamp
Formats a string to include variables and other strings inside it.
just what you wanted
Reply
#3

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
Reply
#4

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;
}
Reply
#5

its only works when i type only $cash but not works when i type this like "hey i got $cash"
Reply
#6

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;
}
Reply
#7

its giving me undefined symbol strreplace
Reply
#8

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
Reply
#9

try this
Код:
if(strfind(text, "$cash"))
{
      str_replace("$cash", GetPlayerMoney(playerid), text));
}
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)