Question about 'stock' - 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: Question about 'stock' (
/showthread.php?tid=368176)
Question about 'stock' -
ddnbb - 12.08.2012
I'd like to make my own stock like this, how is this possible?
pawn Код:
stock SendMessage(playerid, case,string[]) // something like 'case' or something ?
{
if(case = yellow) SendClientMessage(playerid, COLOR_YELLOW, string);
if(case = red) SendClientMessage(playerid, COLOR_RED, string);
if(case = blue) SendClientMessage(playerid, COLOR_BLUE, string);
else return 0;
}
Please dont ask me why i want it like this, because this is just a quick example of how i want to make my other stock.
PS. Is it possible to make it formated, like this:
SendMessage(playerid, yellow, "%s", Name(playerid)); ?
Re: Question about 'stock' -
leonardo1434 - 12.08.2012
here goes.
pawn Код:
stock SendMessage(playerid,color[],string[])
{
if(strcmp(color,#yellow)) return SendClientMessage(playerid, COLOR_YELLOW, string);
else if(strcmp(color,#red)) return SendClientMessage(playerid, COLOR_RED, string);
else if(strcmp(color,#blue)) return SendClientMessage(playerid, COLOR_BLUE, string);
return 0;
}
//usage
SendMessage(playerid,#yellow,#Fuck Yeah);
Re: Question about 'stock' -
ddnbb - 12.08.2012
Quote:
Originally Posted by leonardo1434
here goes.
pawn Код:
stock SendMessage(playerid,color[],string[]) { if(strcmp(color,#yellow)) return SendClientMessage(playerid, COLOR_YELLOW, string); else if(strcmp(color,#red)) return SendClientMessage(playerid, COLOR_RED, string); else if(strcmp(color,#blue)) return SendClientMessage(playerid, COLOR_BLUE, string); return 0; }
//usage SendMessage(playerid,#yellow,#Fuck Yeah);
|
'#' is the only way? Okay, thank you for help!
Re: Question about 'stock' -
leonardo1434 - 12.08.2012
i just use "#" cause it's practical, it does the same as " ".
Re: Question about 'stock' -
ddnbb - 12.08.2012
[quote]
Quote:
Originally Posted by leonardo1434
here goes.
pawn Код:
stock SendMessage(playerid,color[],string[]) { if(strcmp(color,#yellow)) return SendClientMessage(playerid, COLOR_YELLOW, string); else if(strcmp(color,#red)) return SendClientMessage(playerid, COLOR_RED, string); else if(strcmp(color,#blue)) return SendClientMessage(playerid, COLOR_BLUE, string); return 0; }
//usage SendMessage(playerid,#yellow,#Fuck Yeah);
|
Umm, this doesnt work. I made this:
pawn Код:
SendMessage(playerid, #yellow, "YELLOW MESSAGE");
SendMessage(playerid, #red, "RED MESSAGE");
SendMessage(playerid, #blue, "BLUE MESSAGE");
and i got:
pawn Код:
YELLOW MESSAGE
RED MESSAGE
YELLOW MESSAGE
The blue message was replaced with yellow message, why?