SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/03/2015, 12:26 AM   #1
RedCode
Big Clucker
 
RedCode's Avatar
 
Join Date: Jan 2015
Posts: 77
Reputation: 2
Default deleted

Deleted

Last edited by RedCode; 16/03/2015 at 12:58 AM. Reason: deleted
RedCode is offline   Reply With Quote
Old 16/03/2015, 12:29 AM   #2
JuanStone
Huge Clucker
 
Join Date: Apr 2014
Posts: 274
Reputation: 22
Default Respuesta: Random numbers

PHP Code:
CMD:numbers(playerid,params[])
{
    if(
PlayerData[playerid][proplayer] >= 1)
    {
        new 
string[18];
        
format(stringsizeof(string), "random number: %d"random(11));
        
SendClientMessage(playerid, -1string);
    }
    return 
1;

Using the "random" function could return " 0" i hope it will not be a problem, if there is a problem you can use:

PHP Code:
CMD:numbers(playerid,params[])
{
    if(
PlayerData[playerid][proplayer] >= 1)
    {
        new 
string[18];
        
format(stringsizeof(string), "random number: %d"random(10)+1);
        
SendClientMessage(playerid, -1string);
    }
    return 
1;

JuanStone is offline   Reply With Quote
Old 16/03/2015, 12:31 AM   #3
RedCode
Big Clucker
 
RedCode's Avatar
 
Join Date: Jan 2015
Posts: 77
Reputation: 2
Default Re: Random numbers

but if he use that command can be and 0 of them ? i need only from 1 to 11
RedCode is offline   Reply With Quote
Old 16/03/2015, 12:36 AM   #4
JuanStone
Huge Clucker
 
Join Date: Apr 2014
Posts: 274
Reputation: 22
Default Respuesta: Random numbers

try this.

Quote:
Originally Posted by JuanStone View Post
PHP Code:
CMD:numbers(playerid,params[])
{
    if(
PlayerData[playerid][proplayer] >= 1)
    {
        new 
string[18];
        
format(stringsizeof(string), "random number: %d"random(10)+1);
        
SendClientMessage(playerid, -1string);
    }
    return 
1;

JuanStone is offline   Reply With Quote
Old 16/03/2015, 12:38 AM   #5
Jefff
Banned
 
Join Date: Dec 2007
Posts: 2,594
Reputation: 326
Default Re: Random numbers

(random(11) + 1) will be 1-11
Jefff is offline   Reply With Quote
Old 16/03/2015, 12:41 AM   #6
RedCode
Big Clucker
 
RedCode's Avatar
 
Join Date: Jan 2015
Posts: 77
Reputation: 2
Default Re: Random numbers

Jefff if i use that randrom 11+1 when he use command can be and number 12
RedCode is offline   Reply With Quote
Old 16/03/2015, 12:46 AM   #7
JuanStone
Huge Clucker
 
Join Date: Apr 2014
Posts: 274
Reputation: 22
Default Respuesta: Random numbers

The function random starts in 0, if you use 11+1 would be 0+1 to 11 (limit 11 +1-1), Jeff did it well.

PHP Code:
CMD:numbers(playerid,params[])
{
    if(
PlayerData[playerid][proplayer] >= 1)
    {
        new 
string[18];
        
format(stringsizeof(string), "random number: %d"random(11)+1); // 0+1 - 10+1 limit 11.
        
SendClientMessage(playerid, -1string);
    }
    return 
1;


random(11) = "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10"+1 = random 1-11. start in 0.
JuanStone is offline   Reply With Quote
Old 16/03/2015, 12:57 AM   #8
RedCode
Big Clucker
 
RedCode's Avatar
 
Join Date: Jan 2015
Posts: 77
Reputation: 2
Default Re: Random numbers

Thanks guys ! +REP
RedCode is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random numbers viddo Scripting Help 2 31/12/2014 07:42 PM
Random numbers Jimbo01 Help Archive 2 01/02/2011 08:45 PM
[Help] Random numbers Rainbow_Six Help Archive 4 21/10/2010 07:08 PM
[HELP] Random numbers? SiJ Help Archive 6 09/08/2009 03:14 PM
Need help with random numbers... *BueNoOo* Help Archive 11 18/06/2009 05:13 PM


All times are GMT. The time now is 09:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.