SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 29/09/2017, 09:34 PM   #1
GuilhermeNunes
Gangsta
 
Join Date: Feb 2017
Posts: 552
Reputation: 8
Default /sortear

Alguém faz um cmd pra min /sortear [QUANTIDADE]
que sortei dinheiro ex

/sortear 1000

ai escolhe alguem aleatoriamente e da o dinheiro.
GuilhermeNunes is offline   Reply With Quote
Old 29/09/2017, 09:41 PM   #2
F1N4L
High-roller
 
F1N4L's Avatar
 
Join Date: Jun 2013
Location: Brazil
Posts: 2,704
Reputation: 246
Default Re: /sortear

Code:
CMD:sortear(playerid, params[])
{
	new playerRand = random(GetPlayerPoolSize());

	GivePlayerMoney(playerRand, strval(params));

	return true;
}
Lógica extremamente simples e que pode dar problema caso o ID não esteja conectado. Mas como exemplo, serve.
F1N4L is offline   Reply With Quote
Old 29/09/2017, 09:52 PM   #3
Kamper
Guest
 
Posts: n/a
Default Re: /sortear

Quote:
Originally Posted by F1N4L View Post
Code:
CMD:sortear(playerid, params[])
{
	new playerRand = random(GetPlayerPoolSize());

	GivePlayerMoney(playerRand, strval(params));

	return true;
}
Lógica extremamente simples e que pode dar problema caso o ID não esteja conectado. Mas como exemplo, serve.
Incrementei seu solução para ficar 100% funcional.

PHP Code:
CMD:sortear(playeridparams[])
{    
    new 
playerRand;
    do {
        
playerRand random(GetPlayerPoolSize());
    } while (!
IsPlayerConnected(playerRand));

    
GivePlayerMoney(playerRandstrval(params));

    return 
true;

  Reply With Quote
Old 29/09/2017, 10:33 PM   #4
RodrigoMSR
Gangsta
 
RodrigoMSR's Avatar
 
Join Date: Mar 2015
Location: Paraná - Brasil
Posts: 958
Reputation: 129
Default Re: /sortear

PHP Code:
CMD:sortear(playeridparams[])
{
    new 
player[MAX_PLAYERS], count 0;
    for(new 
0GetPlayerPoolSize()+1mi++)
    {
        if(
IsPlayerConnected(i))
        {
            
player[count] = i;
            
count++;
        }
    }
    new 
sorteado player[random(count)];
    
    
GivePlayerMoney(sorteadostrval(params));
    return 
1;

__________________
Asus Prime H310M-K, i5-8400 Six-core @ 3.8GHz, GTX 1060 6GB, 16GB DDR4-2400.
RodrigoMSR 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
[AJUDA] /sortear viniborn Hancoc Português/Portuguese 5 07/04/2012 02:14 AM


All times are GMT. The time now is 11:08 PM.


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