Pvar Strings - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pvar Strings (
/showthread.php?tid=558101)
Pvar Strings -
TheRaGeLord - 16.01.2015
Hello Guys, Can Anyone Tell me the Function of PVar string With Some explanation In His Own Words.. Please Don't Hive the link of wiki.sa-mp
Respuesta: Pvar Strings -
Cerealguy - 16.01.2015
REMOVE THIS, He had misunderstood the question, sorry
Respuesta: Pvar Strings -
JuanStone - 16.01.2015
Quote:
Originally Posted by TheRaGeLord
PVar string..
|
Quote:
Originally Posted by Cerealguy
ahmm..
|
Params:
pawn Код:
GetPVarString(playerid, varname[], string_return[], len);
SetPVarString(playerid, varname[], string_value[]);
Example text input in pvarstring the player:
pawn Код:
command(textinpvarstringname, player, params[])
{
new g_string[16], g_name_pvartstring[16]; // g_string is
if(sscanf(params, "s[16]s[16]", g_name_pvartstring, g_string)) return SendClientMessage(playerid, -1, "usage: /.. name_var string_text"); // usage
if(strlen(g_name_pvartstring) >= 1 && strlen(g_name_pvartstring) < 16 && strlen(g_string) >= 1 && strlen(g_string) < 16) // not text invalid
{
new g_format[83]; // 52 text formar + 15 max name var + 15 max text in the string + 1 null.
SetPVarString(playerid, g_name_pvartstring, g_string, strlen(g_string)); // setpvarstring(playerid, name_var, text/string, sizeof-string);
format(g_format, sizeof(g_format), "Hello, your pvarstring is: name: %s - text in string: %s", g_name_pvartstring, g_string); // format info
SendClientMessage(playerid, -1, g_format); // Send Message
}
else
{
SendClientMessage(playerid, -1, "Name to strig(text) incorrect, min. 1 character, max 15+1null."); // if is text to name var invalid < 0 to > 15 characters.
}
return true;
}
Example command to load and save text in a variable called name_pvarstring
pawn Код:
command(savetextpvstring, playerid, params[])
{
new g_string[16]; // string save in pvarstring
if(sscanf(params, "s[16]", g_string)) return SendClientMessage(playerid, -1, "usage: /savetextpvstring text"); // usage
if(strlen(g_string) >= 1 && strlen(g_string) < 16) // if not invalid text in string
{
SetPVarString(playerid, "name_pvarstring", g_string); // set var string name "name_pvarstring" in string "g_string"
SendClientMessage(playerid, -1, "Text save in pvartstring name: name_pvarstring"); // Send Message player info
}
else
{
SendClientMessage(playerid, -1, "Text incorrect, min 1 character, max 15+1null."); // if is invalid text save in pvartstring
}
return true;
}
command(loadtextpvstring, playerid, params[])
{
new g_string[16], format[67]; // g_string = string in your load text in your pvar string. format info action.
GetPVarString(playerid, "name_pvarstring", g_string, strlen(g_string)); // Getstringtext the playerid, name var "name_pvarstring", load text in string g_string, size = strlen(gstrign)
format(format, sizeof(format), "Your text un pvartstring name: name_pvarstring is: %s", g_string); //format info
SendClientMessage(playerid, -1, format); // Sen message playerid info
return true;
}