11.03.2012, 18:45
(
Последний раз редактировалось Carbonite; 30.04.2012 в 20:49.
)
Hello SA-MP community!
I have been webcoding and I found this community through a friend of mine. I want to make my own popular server for people to play on someday and for now I just want to learn the Pawn scripting so I could become more experienced before I open a whole community to this community. To do this I've been going through SA-MP wiki and started my own gamemode which is being tested by me and me only.
SendMessage(playerid, Sscanf[], {Float,_}:...);
The code is above, installation is simple... Copy, Paste, and Compile.
An example usage of this code is...
Which in the chat box will display...
Carbonite's SendMessage function.
This was tested and works 100%!
How to add more color options?
See...
Just change NumberOfColors = 10 to NumberOfColors = 11
Then add...
... after ...
Example...
Tell me how I'm doing so far...
Comment and Rate please.
Make suggestions.
Be kind and courteous.
Thank you for your time.
I have been webcoding and I found this community through a friend of mine. I want to make my own popular server for people to play on someday and for now I just want to learn the Pawn scripting so I could become more experienced before I open a whole community to this community. To do this I've been going through SA-MP wiki and started my own gamemode which is being tested by me and me only.
SendMessage(playerid, Sscanf[], {Float,_}:...);
Код:
stock SendMessage(PlayerID, Sscanf[], {Float,_}:...) {
if(!IsPlayerConnected(PlayerID)) return false;
new
String[500];
for(new SscanfString = 0; SscanfString < (numargs() - 1); SscanfString++) {
switch(Sscanf[SscanfString]) {
case 's': {
new
Result[100];
for(new ResultString = 0; getarg((SscanfString + 2), ResultString) != 0; ResultString++) {
Result[ResultString] = getarg((SscanfString + 2), ResultString);
}
if(!strlen(String)) {
format(String, 500, "%s", Result);
} else format(String, 500, "%s%s", String, Result);
}
case 'd', 'i': {
new
Result = getarg(SscanfString + 2);
if(!strlen(String)) {
format(String, 500, "%d", Result);
} else format(String, 500, "%s%d", String, Result);
}
case 'f': {
new
Float: Result = Float: getarg(SscanfString + 2);
if(!strlen(String)) {
format(String, 500, "%f", Result);
} else format(String, 500, "%s%f", String, Result);
}
case 'c': {
new
Result[100];
for(new ResultString = 0; getarg((SscanfString + 2), ResultString) != 0; ResultString++) {
Result[ResultString] = getarg((SscanfString + 2), ResultString);
}
new
NumberOfColors = 10,
Colors[][][] = {
{ "Black", "{000000}" },
{ "Grey", "{C0C0C0}" },
{ "White", "{FFFFFF}" },
{ "Red", "{FF0000}" },
{ "Orange", "{FF8000}" },
{ "Yellow", "{FFFF00}" },
{ "Green", "{00FF00}" },
{ "Blue", "{0000FF}" },
{ "Purple", "{800080}" },
{ "Teal", "{008080}" }
};
for(new NumColors = 0; NumColors < NumberOfColors; NumColors++) {
if(strcmp(Result, Colors[NumColors][0], true) == 0) {
if(!strlen(String)) {
format(String, 500, "%s", Colors[NumColors][1]);
} else format(String, 500, "%s%s", String, Colors[NumColors][1]);
}
}
}
}
}
SendClientMessage(PlayerID, -1, String);
return true;
}
An example usage of this code is...
Код:
SendMessage(playerid, "cscs", "Teal", "Carbonite's ", "Red", "SendMessage function.");
Carbonite's SendMessage function.
This was tested and works 100%!
How to add more color options?
See...
Код:
new
NumberOfColors = 10,
Colors[][][] = {
{ "Black", "{000000}" },
{ "Grey", "{C0C0C0}" },
{ "White", "{FFFFFF}" },
{ "Red", "{FF0000}" },
{ "Orange", "{FF8000}" },
{ "Yellow", "{FFFF00}" },
{ "Green", "{00FF00}" },
{ "Blue", "{0000FF}" },
{ "Purple", "{800080}" },
{ "Teal", "{008080}" }
};
Then add...
Код:
,
{ "Color", "{RRGGBB}" }
Код:
{ "Teal", "{008080}" }
Код:
new
NumberOfColors = 11,
Colors[][][] = {
{ "Black", "{000000}" },
{ "Grey", "{C0C0C0}" },
{ "White", "{FFFFFF}" },
{ "Red", "{FF0000}" },
{ "Orange", "{FF8000}" },
{ "Yellow", "{FFFF00}" },
{ "Green", "{00FF00}" },
{ "Blue", "{0000FF}" },
{ "Purple", "{800080}" },
{ "Teal", "{008080}" },
{ "Brown", "{732F02}" }
};
Comment and Rate please.
Make suggestions.
Be kind and courteous.
Thank you for your time.

