How to do this things? - 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: How to do this things? (
/showthread.php?tid=635562)
How to do this things? -
akib - 09.06.2017
Hi,
How to divide player first name and last name....
example:
Код:
new m[126];
format(m,sizeof(m),"Your first name is %s",firstname);
SendClientMessage(playerid,-1,m);
and 2nd function is...
How to do random colors?
Onplayer login
show player login dialog
in login dialog
Welcome [Random Color]Playername
Re: How to do this things? -
Whatname - 09.06.2017
PHP код:
new rand = random(5);
switch(rand)
{
case 0: format(m,sizeof(m),"Your first name is {00FF00}%s",firstname); //green
case 1: format(m,sizeof(m),"Your first name is {FF0000}%s",firstname); //red
case 2: format(m,sizeof(m),"Your first name is {FFFF00}%s",firstname); //yellow
//etc
}
SendClientMessage(playerid, -1, m);
Re: How to do this things? -
akib - 09.06.2017
Quote:
Originally Posted by Whatname
PHP код:
new rand = random(5);
switch(rand)
{
case 0: format(m,sizeof(m),"Your first name is {00FF00}%s",firstname); //green
case 1: format(m,sizeof(m),"Your first name is {FF0000}%s",firstname); //red
case 2: format(m,sizeof(m),"Your first name is {FFFF00}%s",firstname); //yellow
//etc
}
ShowPlayerDialog(playerid, dialogid, type, "header", m, "Ok", "");
|
i said how to divide first name and last name -_-
Re: How to do this things? -
Whatname - 09.06.2017
Quote:
Originally Posted by akib
i said how to divide first name and last name -_-
|
You also asked "How to do random colors?"
Re: How to do this things? -
akib - 09.06.2017
Quote:
Originally Posted by Whatname
You also asked "How to do random colors?"
|
Код:
format(string, sizeof string, "{FFFFF}Welcome {do here random color}%s{FFFFFF}\n{FFFFFF}Please register by entering your password in the field below:", Player[playerid][Name]);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "BARP | Registration", string, "Register", "Abort");
Re: How to do this things? -
Threshold - 09.06.2017
God damn... some people...
http://lmgtfy.com/?q=samp%20divide%2...%20last%20name
Not that hard, honestly.
Re: How to do this things? -
Whatname - 09.06.2017
-REMOVED-
Re: How to do this things? -
Vince - 09.06.2017
Quote:
Originally Posted by Whatname
PHP код:
new rand = random(5);
switch(rand)
{
case 0: format(m,sizeof(m),"Your first name is {00FF00}%s",firstname); //green
case 1: format(m,sizeof(m),"Your first name is {FF0000}%s",firstname); //red
case 2: format(m,sizeof(m),"Your first name is {FFFF00}%s",firstname); //yellow
//etc
}
SendClientMessage(playerid, -1, m);
|
https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
Re: How to do this things? -
Whatname - 09.06.2017
Quote:
Originally Posted by Vince
|
Ok
PHP код:
#include <a_samp>
#include <izcmd>
static const RandCol[][]=
{
"{00FF00}", "{FF0000}", "{FFFF00}"
};
CMD:testrcol(playerid, params[])
{
new string[15];
new rand = random(sizeof(RandCol));
format(string, sizeof(string), "%s hello.", RandCol[rand]);
SendClientMessage(playerid, -1, string);
return 1;
}
now better
Re: How to do this things? -
StaticYey - 09.06.2017
PHP код:
new playerName[MAX_PLAYER_NAME];
new slicedName[2][MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
split(playerName, slicedName, '_');
printf("Your firstname is %s and your lastname is %s.", slicedName[0], slicedName[1]);
Use
slicedName[0] and
slicedName[1] for the
first name and
last name respectively.