SA-MP Forums Archive
This or That? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: This or That? (/showthread.php?tid=471813)



This or That? - Lajko1 - 25.10.2013

Which one is correct..
This:
pawn Код:
if(strcmp(cmd, "/coin", true) == 0)
    {
        if(IsDown[playerid] == 1 || IsDown[playerid] == 2) { return SendClientMessage(playerid,0xFF0000AA,"You can't do this while incapacitated."); }
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new coin = random(2)+1;
            new coinname[20];
            if(coin == 1) { coinname = "head"; }
            else { coinname = "tail"; }
            format(string, sizeof(string), "*%s flips a coin that lands on a %s", sendername,coinname);
            ProxDetector(8.0, playerid, string,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA);
        }
        if(Masked[playerid] == 1) string = "*Stranger flips a coin that lands on a %s";
        else format(string, sizeof(string), "*%s flips a coin that lands on a %s", sendername,coinname);
        ProxDetector(8.0, playerid, string,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA);
        return 1;
    }
or that:
pawn Код:
if(strcmp(cmd, "/coin", true) == 0)
    {
        if(IsDown[playerid] == 1 || IsDown[playerid] == 2) { return SendClientMessage(playerid,0xFF0000AA,"You can't do this while incapacitated."); }
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new coin = random(2)+1;
            new coinname[20];
            if(coin == 1) { coinname = "head"; }
            else { coinname = "tail"; }
        }
        if(Masked[playerid] == 1) string = "*Stranger flips a coin that lands on a %s";
        else format(string, sizeof(string), "*%s flips a coin that lands on a %s", sendername,coinname);
        ProxDetector(8.0, playerid, string,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA);
        return 1;
    }



Re: This or That? - CrazyChoco - 25.10.2013

Why don't you try it instead of waiting for replies..


Re: This or That? - Konstantinos - 25.10.2013

I'd improve it a bit.

pawn Код:
if(!strcmp(cmd, "/coin", true))
{
    if(IsDown[playerid] == 1 || IsDown[playerid] == 2) return SendClientMessage(playerid,0xFF0000AA,"You can't do this while incapacitated.");
    if(Masked[playerid] == 1) format(string, sizeof(string), "*Stranger flips a coin that lands on a %s", (random(2) == 1) ? ("head") : ("tail"));
    else
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "*%s flips a coin that lands on a %s", sendername, (random(2) == 1) ? ("head") : ("tail"));
    }
    ProxDetector(8.0, playerid, string,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA,0x33CCFFAA);
    return 1;
}



Re: This or That? - Lajko1 - 25.10.2013

Thank you