SA-MP Forums Archive
Just a test. - 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: Just a test. (/showthread.php?tid=368868)



Just a test. - TaLhA XIV - 14.08.2012

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.


Re: Just a test. - IstuntmanI - 14.08.2012

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 )


Re: Just a test. - Jefff - 14.08.2012

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;
}



Re: Just a test. - TaLhA XIV - 14.08.2012

Thanks both.


Re: Just a test. - Akcent_Voltaj - 14.08.2012

DELETE TOO LATE sorry.


Re: Just a test. - TaLhA XIV - 15.08.2012

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.


Re: Just a test. - [MM]RoXoR[FS] - 15.08.2012

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


Re: Just a test. - TaLhA XIV - 15.08.2012

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




Re: Just a test. - TaLhA XIV - 15.08.2012

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


Re: Just a test. - TaLhA XIV - 15.08.2012

help.