Duda con el dinero :s
#1

Hola a todos
Como hago para que alguien no pueda comprar algo si no tiene la cantidad de dinero exacta?
Reply
#2

pawn Код:
if(GetPlayerMoney(playerid) < value)
https://sampwiki.blast.hk/wiki/GetPlayerMoney
Reply
#3

Puede ir asi

PHP код:
COMMAND:buy(playeridparams[])
{
    if(!
PlayerMoneyCheck(playerid0xFFFFFFFF200))
        return 
0;
    
SendClientMessage(playerid, -1"Listo!");
    return 
1;
}
stock PlayerMoneyCheck(playeridcolormoney)
{
    if(!
IsPlayerConnected(playerid))
        return 
0;
    new
        
str[64],
        
need = (money GetPlayerMoney(playerid));
    if(
need 1)
        return 
1;
        
    
format(strsizeof str"Te faltan $%d"need);
     
SendClientMessage(playeridcolorstr);
    return 
0;

Reply
#4

pawn Код:
COMMAND:buy(playerid, params[])
{
    if(!ConfirmPlayerPurchase(playerid, 0xFFFFFFFF, 200)) return 1;

    SendClientMessage(playerid, -1, "Listo!");
    return 1;
}

stock ConfirmPlayerPurchase(playerid, color, money)
{
    if(!IsPlayerConnected(playerid)) return 0;

    new need = (GetPlayerMoney(playerid) - money);

    if(need >= 0) return 1;

    new string[64];

    format(string, sizeof(string), "Te faltan $%d.", (need) * (-1));
    SendClientMessage(playerid, color, string);
    return 0;
}
Reply
#5

Quote:
Originally Posted by _Zume
Посмотреть сообщение
Puede ir asi

PHP код:
COMMAND:buy(playeridparams[])
{
    if(!
PlayerMoneyCheck(playerid0xFFFFFFFF200))
        return 
0;
    
SendClientMessage(playerid, -1"Listo!");
    return 
1;
}
stock PlayerMoneyCheck(playeridcolormoney)
{
    if(!
IsPlayerConnected(playerid))
        return 
0;
    new
        
str[64],
        
need = (money GetPlayerMoney(playerid));
    if(
need 1)
        return 
1;
        
    
format(strsizeof str"Te faltan $%d"need);
     
SendClientMessage(playeridcolorstr);
    return 
0;

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
COMMAND:buy(playerid, params[])
{
    if(!ConfirmPlayerPurchase(playerid, 0xFFFFFFFF, 200)) return 1;

    SendClientMessage(playerid, -1, "Listo!");
    return 1;
}

stock ConfirmPlayerPurchase(playerid, color, money)
{
    if(!IsPlayerConnected(playerid)) return 0;

    new need = (GetPlayerMoney(playerid) - money);

    if(need >= 0) return 1;

    new string[64];

    format(string, sizeof(string), "Te faltan $%d.", (need) * (-1));
    SendClientMessage(playerid, color, string);
    return 0;
}
Gracias pero me funciono lo de Enzo
Reply
#6

Quote:
Originally Posted by AdrianGN1
Посмотреть сообщение
Gracias pero me funciono lo de Enzo
Todos funcionan.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)