Just a test.
#1

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/coin"cmdtexttrue10) == 0)
    {
        new 
str[150];
        
GetPlayerName(playeridstrsizeof(str));
        
format(strsizeof(str), "{0780E3}%s flips the coin and lands it on((heads||tails))"str);
        
SendClientMessageToAll(-1,str);
        return 
1;
    }
    return 
0;

Just ried this one I posted this,I never went on this side so can someone help that how to give random message and change head and tails every time the command is applied.
Reply
#2

Use 'random' function and a 'switch' :
Код:
if( strcmp( cmdtext, "/coin", cmdtext, true ) == 0 ) 
{ 
	new str[ 128 ]; 
	GetPlayerName( playerid, str, MAX_PLAYER_NAME );
	switch( random( 2 ) )
	{
		case 0: format( str, 128, "%s flips the coin and lands it on heads", str );
		case 1: format( str, 128, "%s flips the coin and lands it on tails", str );
	}
	SendClientMessageToAll( 0x0780E3FF, str ); 
	return 1; 
}
( I also improoved your code )
Reply
#3

or
pawn Код:
#define conv(%0,%1,%2) ((!%0) ? (%1) : (%2))

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/coin", cmdtext, true) == 0)
    {
        new str[150];
        static result;
        result %= 2;
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "{0780E3}%s flips the coin and lands it on %s", str,conv(result,"heads","tails"));
        SendClientMessageToAll(-1,str);
        result++;
        return 1;
    }
    return 0;
}
Reply
#4

Thanks both.
Reply
#5

DELETE TOO LATE sorry.
Reply
#6

How can I do it like if I do /coin the result is random.Like if I do /coin it appears heads,and the second time I do it is also random like no one knows that what is the result,it might come tails or heads.
Reply
#7

Quote:
Originally Posted by TaLhA XIV
Посмотреть сообщение
How can I do it like if I do /coin the result is random.Like if I do /coin it appears heads,and the second time I do it is also random like no one knows that what is the result,it might come tails or heads.
If you use code by costel_nistor96
pawn Код:
if( strcmp( cmdtext, "/coin", cmdtext, true ) == 0 )
{
    new str[ 128 ];
    GetPlayerName( playerid, str, MAX_PLAYER_NAME );
    switch( random( 2 ) )
    {
        case 0: format( str, 128, "%s flips the coin and lands it on heads", str );
        case 1: format( str, 128, "%s flips the coin and lands it on tails", str );
    }
    SendClientMessageToAll( 0x0780E3FF, str );
    return 1;
}
it will ALWAYS be RANDOM
Reply
#8

PHP код:
ProxDetector(10.0playeridstrCOLOR_PINKCOLOR_PINKCOLOR_PINKCOLOR_PINKCOLOR_PINK); 
error:
PHP код:
C:\Users\TaLhA XIV\Desktop\Pawno scripter\filterscripts\dice.pwn(104) : error 017undefined symbol "ProxDetector"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase


1 Error

Reply
#9

okay just tell how can I make a range of chat.
Reply
#10

help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)