Others

These are not tested for the latest version of sa-mp.


RandomCash(min, max);

By LuxeoN, changed slightly by WeeDarr

public RandomCash(min, max)
{
    return random(max - min) + min;
}

Usage:

new rndcash = RandomCash(10, 20); // min and max cash amount
GivePlayerMoney(playerid, rndcash);

Top


GivePlayerHealth(playerid, Float:health);

By WeeDarr

GivePlayerHealth(playerid, Float:health)
{
    new Float:phealth[MAX_PLAYERS];
    GetPlayerHealth(playerid, phealth[playerid]);
    SetPlayerHealth(playerid, phealth[playerid] + health);
}

Usage:

GivePlayerHealth(playerid, 35.0);

Top


Random checkpoint

By LuxeoN

Top of script (Where all 'new variables' are:

new Float:RandFCP[8][3] =
{
    {-2454.2170, 503.8759, 30.0790},
    {-2669.7322, -6.0874, 6.1328}, 
    {-2796.9854, 1224.8180, 20.5429},
    {-2454.2170, 503.8759, 30.0790},
    {-2669.7322, -6.0874, 6.1328},
    {-2796.9854, 1224.8180, 20.5429},
    {-2454.2170, 503.8759, 30.0790},
    {-2669.7322, -6.0874, 6.1328}
}

Into the command or wherever you want:

SetPlayerCheckpoint(playerid,RandFCP[random(sizeof(RandFCP))][0], RandFCP[random(sizeof(RandFCP))][1], RandFCP[random(sizeof(RandFCP))][2]);

Top


Randomising command

By LuxeoN

Forwarding natives:

forward FirstResult(playerid);
forward SecondResult(playerid);

Put this somewhere ,but not in ready native:

public FirstResult(playerid)
{
    GameTextForPlayer(playerid,"~w~First result worked!",5000, 5);
    //other functions
    return 1;
}
public SecondResult(playerid)
{
    GameTextForPlayer(playerid,"~w~Second result worked!",5000, 5);
    //other functions
    return 1;
}

Under OnPlayerCommandText() :

if (strcmp("/randomcommand", cmdtext, true, 8) == 0)
{
    if(random(100) < 50)    // 50%
    {
        SetTimerEx("FirstResult", 1000, 0, "i", playerid);
        //other functions
    }
    else
    {
        SetTimerEx("SecondResult", 1000, 0, "i", playerid);
        //other functions
    }
    return 1;
}

Now go and test it!

Top


EightBall(playerid)

By WeeDarr

EightBall(playerid)
{
    if(random(500) < 25) return SendClientMessage(playerid, 0xFFFF00AA, "Signs point to yes.");
    else if(random(500) >= 25 && random(500) < 50) return SendClientMessage(playerid, 0xFFFF00AA, "Yes.");
    else if(random(500) >= 50 && random(500) < 75) return SendClientMessage(playerid, 0xFFFF00AA, "Reply hazy, try again.");
    else if(random(500) >= 75 && random(500) < 100) return SendClientMessage(playerid, 0xFFFF00AA, "Without a doubt.");
    else if(random(500) >= 100 && random(500) < 125) return SendClientMessage(playerid, 0xFFFF00AA, "My sources say no.");
    else if(random(500) >= 125 && random(500) < 150) return SendClientMessage(playerid, 0xFFFF00AA, "As I see it, yes.");
    else if(random(500) >= 150 && random(500) < 175) return SendClientMessage(playerid, 0xFFFF00AA, "You may rely on it.");
    else if(random(500) >= 175 && random(500) < 200) return SendClientMessage(playerid, 0xFFFF00AA, "Concentrate and ask again.");
    else if(random(500) >= 200 && random(500) < 225) return SendClientMessage(playerid, 0xFFFF00AA, "Outlook not so good.");
    else if(random(500) >= 225 && random(500) < 250) return SendClientMessage(playerid, 0xFFFF00AA, "It is decidedly so.");
    else if(random(500) >= 250 && random(500) < 275) return SendClientMessage(playerid, 0xFFFF00AA, "Better not tell you now.");
    else if(random(500) >= 275 && random(500) < 300) return SendClientMessage(playerid, 0xFFFF00AA, "Very doubtful.");
    else if(random(500) >= 300 && random(500) < 325) return SendClientMessage(playerid, 0xFFFF00AA, "Yes - definitely.");
    else if(random(500) >= 325 && random(500) < 350) return SendClientMessage(playerid, 0xFFFF00AA, "It is certain.");
    else if(random(500) >= 350 && random(500) < 375) return SendClientMessage(playerid, 0xFFFF00AA, "Cannot predict now.");
    else if(random(500) >= 375 && random(500) < 400) return SendClientMessage(playerid, 0xFFFF00AA, "Most likely.");
    else if(random(500) >= 400 && random(500) < 425) return SendClientMessage(playerid, 0xFFFF00AA, "Ask again later.");
    else if(random(500) >= 425 && random(500) < 450) return SendClientMessage(playerid, 0xFFFF00AA, "My reply is no.");
    else if(random(500) >= 450 && random(500) < 475) return SendClientMessage(playerid, 0xFFFF00AA, "Outlook good.");
    else if(random(500) >= 475 && random(500) < 500) return SendClientMessage(playerid, 0xFFFF00AA, "Don't count on it.");
    return 1;
}

Usage:

if (strcmp("/test", cmdtext, true, 5) == 0)
{
    EightBall(playerid);
    return 1;
}

Top



Back | Home