[HELP] Scripting - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Scripting (
/showthread.php?tid=75609)
[HELP] Scripting -
mannu - 03.05.2009
Could u please tell me this (read please)
Player(mannu) do the command /hi <id>.
and then it send Message to player "mannu said hi to you"
Now here's the prob
How would i print the mesage to praticular id
like how do print the name of player doing command and how do i send it to that particlur id please tell
Re: [HELP] Scripting -
MenaceX^ - 03.05.2009
You need ReturnUser and strtok.
Re: [HELP] Scripting -
GTA_Rules - 03.05.2009
pawn Код:
if(strcmp(cmd, "/hi", true) == 0)
{
new tmp[256], string[256], str[256], PlayerName[24], OtherPlayerName[24];
tmp = strtok(cmdtext, idx);
new OtherPlayer = strval(tmp);
GetPlayerName( OtherPlayer, OtherPlayerName, 24 );
GetPlayerName( playerid, PlayerName, 24 );
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hi <playerid>");
if(!IsPlayerConnected(OtherPlayer)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Playerid.");
if(OtherPlayer == playerid) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You cannot say hi to yourself!");
format(string, sizeof(string), "You have said hi to %s.", OtherPlayerName);
format(str, sizeof(str), "%s said hi to you.", PlayerName);
SendClientMessage(playerid, COLOR_GREEN, string);
SendClientMessage(OtherPlayer, COLOR_GREEN, str);
return 1;
}
Re: [HELP] Scripting -
mannu - 03.05.2009
Thanks both of you
but please tell me line to line usage i mean what each line if for and what it means
Re: [HELP] Scripting -
mannu - 03.05.2009
help please
Re: [HELP] Scripting -
HB - 03.05.2009
Matthias, read
this before posting any code. Also, this code isn't really "newbie" friendly.
Try writing this command by your own. This is how you should do it: Create a string with 128 as string size. Get the name of the player and put them together into a message. Use %s for a string and %d for a number(in case you want the playerid there also). Send them to all the players, and you have done one part.
Re: [HELP] Scripting -
[LSB]Clinz - 04.05.2009
Код:
if (strcmp(cmd, "/hi",true) == 0)
{
if (IsPlayerConnected(giveplayerid))
{
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid,0xFFFFFFAA," USAGE: /hi [playerid]");
return 1;
}
new giveplayerid = ReturnUser(tmp, playerid);
tmp = strtok(cmdtext, idx);
if (giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), " * %s said hi to you!", giveplayername);
SendClientMessage(giveplayerid, 0xFFFFFFAA, string);
}
else SendClientMessage(playerid,0xFFFFFFAA," * Player is not connected!");
return 1;
}
You need the ReturnUser function then and obviously strtok.