Jump to content
  • 0

Nu se executa comanda atunci cand o dau


Question

Posted (edited)

Salut, de data asta, am o problema mai ciudata, care nu am mai intalnit o pana acum.

Adica cand dau comanda prima data nu merge, dar daca o spamez de multe ori pana la urma merge.

Aceasta este comanda:
 

 CMD:trylucky(playerid, params[])
{
    new amount, string[64], rand = random(50);
    if(!PlayerToPoint(2.0, playerid, 386.7224,-1817.7662,7.8409))
    {
        SetPlayerCheckpointEx(playerid, 386.7224,-1817.7662,7.8409, 5.0);
        CP[playerid] = 678; 
        SCM(playerid, COLOR_GREY, "You are not at the right place.");
        SCM(playerid, COLOR_YELLOW, "Ti-am pus un checkpoint catre locatie, du-te la el!");
        return 1;
    }
    if(sscanf(params, "i", amount)) return SCM(playerid, -1, "{CECECE}USAGE: {FFFFFF}/trylucky <amount>");
    if(amount < 10000) return SCM(playerid, COLOR_GREY, "Suma trebuie sa fie de minim $10.000.");
    if(GetPlayerCash(playerid) < amount) return SCM(playerid, -1, "Nu ai aceasta suma de bani.");

    switch(rand) {
        case 0: 
        {
            format(string, sizeof(string), "You lost $%s.", FormatNumber(amount));
            SCM(playerid, COLOR_GREEN, string);
            GivePlayerCash(playerid, -amount);
            Update(playerid, pCashx);
        }
        case 1:
        {
            format(string, sizeof(string), "Congratulations, %s! You won $%s.", GetName(playerid), FormatNumber(amount+amount));
            SCM(playerid, COLOR_GREEN, string);
            GivePlayerCash(playerid, amount+amount);
            Update(playerid, pCashx);
        }
    }
    return 1;

Edited by Raduq

4 answers to this question

Recommended Posts

  • 0
Posted

Ce parte nu se executa? Ce cu lose/win?

Iti spun exact de ce anume. Rand are valori intre 0-50 tu in switch verifici doar daca rand are valoare 0 sau 1. Probabilitatea ca rand sa ia acezte valori din cele 50 numere este mica de aceea spui ca nu ti se executa comanda mereu

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.