[Ajuda] Simples
#3

pawn Код:
#include <a_samp>
#define LIGHTBLUE    0x0BBF6AA

#define TEAM_RED     0

#define TEAM_BlUE    1

#define COLOR_BLUE  0x0000FFAA
#define COLOR_RED   0xff0010ff
#define COLOR_MSG   0xa9ff43ff
#define COLOR_GREY  0xAFAFAFAA
#define MENU_SHOP   0
//Killing ranks

    new First[MAX_PLAYERS];
    new Double[MAX_PLAYERS];
    new Spree[MAX_PLAYERS];
    new Four[MAX_PLAYERS];
    new Dominat[MAX_PLAYERS];
    new Rampage[MAX_PLAYERS];
    new Monster[MAX_PLAYERS];
    new Six[MAX_PLAYERS];
    new gTeam[MAX_PLAYERS];

new Text:Kills;
new KillsRed;
new KillsBlue;
new GameMinutes =4;
new GameSeconds =59;
new GameTimer;
new Text:Textdraw0;
new Text:Textdraw2;
forward GameModeExitFunc(playerid);forward GameTime(playerid);

#pragma tabsize 0
new RoundTime = 300000;//5 minutes
forward GameTime();
forward GameModeExitFunc(playerid);
new
    Text: text_Top5[2]
;

enum rankingEnum
{
    player_Score,
    player_ID
}


main()
{

    print("\n----------------------------------");
    printf(" Liberty City Mafia \n Create Date: 03/11/2011 Remade By Kairos");
    print("----------------------------------\n");
}

public GameTime()
{
    if(GameSeconds || GameMinutes)
    {
        GameSeconds--;
        if(GameSeconds <= -1)
        {
            GameMinutes--;
            GameSeconds=59;
        }
        new TimeString[256];
        format(TimeString,sizeof(TimeString),"~b~%02d~y~:~r~%02d",GameMinutes,GameSeconds);
        TextDrawSetString(Textdraw0,TimeString);
    }

    return 1;
}

public OnGameModeInit()
{
    for(new i;i<15;++i)
    {
        SendClientMessageToAll(COLOR_RED," ");
    }
    SetGameModeText("Liberty City Mafia");
    UsePlayerPedAnims();
    SetTimer("GameModeExitFunc", RoundTime, 0);
    SetWorldTime(0);
    AddPlayerClass(111, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(124, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
    SetTimer("Score",297000,false);
    Kills = TextDrawCreate(4.000000, 287.000000, "~r~Red: ~w~0~n~~g~Blue: ~w~0");
    TextDrawBackgroundColor(Kills, 255);
    TextDrawFont(Kills, 1);
    TextDrawLetterSize(Kills, 0.540000, 1.760000);
    TextDrawColor(Kills, -16776961);
    TextDrawSetOutline(Kills, 1);
    TextDrawSetProportional(Kills, 1);
    //TextDraw
    GameTimer = SetTimer("GameTime",1000,1);


     Textdraw0 = TextDrawCreate(586.000000, 43.000000,"5:00");
    TextDrawAlignment(Textdraw0,2);
    TextDrawBackgroundColor(Textdraw0,0x000000ff);
    TextDrawFont(Textdraw0,3);
    TextDrawLetterSize(Textdraw0,0.499999,2.000000);
    TextDrawColor(Textdraw0,0xffffffff);
    TextDrawSetOutline(Textdraw0,1);
    TextDrawSetProportional(Textdraw0,1);
    TextDrawSetShadow(Textdraw0,1);

    Textdraw2 = TextDrawCreate(10.000000, 240.000000, "this team is full kindly choose the other team");
    TextDrawBackgroundColor(Textdraw2, 255);
    TextDrawFont(Textdraw2, 1);
    TextDrawLetterSize(Textdraw2, 0.490000, 1.500000);
    TextDrawColor(Textdraw2, -1);
    TextDrawSetOutline(Textdraw2, 0);
    TextDrawSetProportional(Textdraw2, 1);
    TextDrawSetShadow(Textdraw2, 1);
    TextDrawUseBox(Textdraw2, 1);
    TextDrawBoxColor(Textdraw2, 255);
    TextDrawTextSize(Textdraw2, 211.000000, -29.000000);

    text_Top5[0] = TextDrawCreate(79.000000, 135.000000, "Top 5");
    TextDrawAlignment(text_Top5[0], 2);
    TextDrawBackgroundColor(text_Top5[0], 255);
    TextDrawFont(text_Top5[0], 1);
    TextDrawLetterSize(text_Top5[0], 0.280000, 1.499999);
    TextDrawColor(text_Top5[0], -1);
    TextDrawSetOutline(text_Top5[0], 0);
    TextDrawSetProportional(text_Top5[0], 1);
    TextDrawSetShadow(text_Top5[0], 0);

    text_Top5[1] = TextDrawCreate(16.000000, 135.000000, " ");
    TextDrawBackgroundColor(text_Top5[1], 255);
    TextDrawFont(text_Top5[1], 1);
    TextDrawLetterSize(text_Top5[1], 0.200000, 0.999999);
    TextDrawColor(text_Top5[1], -1);
    TextDrawSetOutline(text_Top5[1], 0);
    TextDrawSetProportional(text_Top5[1], 1);
    TextDrawSetShadow(text_Top5[1], 0);
    TextDrawUseBox(text_Top5[1], 1);
    TextDrawBoxColor(text_Top5[1], 150);
    TextDrawTextSize(text_Top5[1], 143.000000, 20.000000);


    return 1;
}

public OnGameModeExit()
{
    return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerInterior(playerid,11);
    SetPlayerPos(playerid,508.7362,-87.4335,998.9609);
    SetPlayerCameraPos(playerid,508.7362,-83.4335,998.9609);
    SetPlayerCameraLookAt(playerid,508.7362,-87.4335,998.9609);
    SetPlayerFacingAngle(playerid,0.0);

    if(classid == 0)
    {
    gTeam[playerid] = TEAM_RED;
    GameTextForPlayer(playerid,"~r~Red ~w~Team",1000,3);
    }
    else if(classid == 1)
    {
    gTeam[playerid] = TEAM_BlUE;
    GameTextForPlayer(playerid,"~g~Blue ~w~Team",1000,3);
    }

    return 1;
}

public OnPlayerConnect(playerid)
{

    GameTextForPlayer(playerid,"~b~Liberty ~y~City ~r~Mafia~w~ !!",3000,1);
    SetPlayerColor(playerid,COLOR_GREY);

    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

    return 1;
}

public OnPlayerSpawn(playerid)
{

    if(gTeam[playerid] == TEAM_RED)
    {
    SetPlayerPos(playerid,-828.202514648,514.817016601,1357.80566406);
    SetPlayerFacingAngle(playerid,90.8542);
    GivePlayerWeapon(playerid,24,500);
    GivePlayerWeapon(playerid,30,500);
    GivePlayerWeapon(playerid,4,2);
    SetPlayerTeam(playerid,1);
    }
    else if(gTeam[playerid] == TEAM_BlUE)
    {
    SetPlayerPos(playerid,-783.37158203125,492.43212890625,1375.4455566406);
    SetPlayerFacingAngle(playerid,90.8776);
    GivePlayerWeapon(playerid,24,500);
    GivePlayerWeapon(playerid,30,500);
    GivePlayerWeapon(playerid,4,2);
    SetPlayerTeam(playerid,2);
    }
    SetPlayerInterior(playerid,1);
    SetCameraBehindPlayer(playerid);
    TextDrawShowForPlayer(playerid,Textdraw0);
 //      TextDrawShowForPlayer(playerid, text_Top5[0]);
//    TextDrawShowForPlayer(playerid, text_Top5[1]);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SetPlayerWantedLevel(playerid, 0);
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);

    GivePlayerMoney(killerid,3000);
    GivePlayerMoney(playerid,-1000);

    if(gTeam[killerid] == TEAM_RED) KillsRed++;
    if(gTeam[killerid] == TEAM_BlUE) KillsBlue++;

    new Stats[256];
    format(Stats,sizeof(Stats),"~r~Red: ~w~%i~n~~g~Blue: ~w~%i",KillsRed,KillsBlue);
    TextDrawSetString(Kills,Stats);
    TextDrawHideForPlayer(playerid, text_Top5[0]);
    TextDrawHideForPlayer(playerid, text_Top5[1]);
//Killing ranks

    First[killerid] ++;
    First[playerid] = 0;

    Spree[killerid] ++;
    Spree[playerid] = 0;

    Double[killerid] ++;
    Double[playerid] = 0;

    Dominat[killerid] ++;
    Dominat[playerid] = 0;

    Rampage[killerid] ++;
    Rampage[playerid] = 0;

    Monster[killerid] ++;
    Monster[playerid] = 0;

    Six[killerid] ++;
    Six[playerid] = 0;

    Four[killerid] ++;
    Four[playerid] = 0;

    if(First[killerid] == 1)
    {
     SetPlayerWantedLevel(killerid, 1);

     }
    if(Double[killerid] == 2)
    {
    new str2[128];
    new kname[MAX_PLAYER_NAME];
    GetPlayerName(killerid,kname,sizeof(kname));
    format(str2,sizeof(str2), " %s(%d) Double Killing",kname,killerid);
    GameTextForAll(str2,4000,3);
    SendClientMessageToAll(LIGHTBLUE,str2);
    SetPlayerWantedLevel(killerid, 2);
    }
    if(Spree[killerid] == 3)
    {
    new str2[128];
    new kname[MAX_PLAYER_NAME];
    GetPlayerName(killerid,kname,sizeof(kname));
    format(str2,sizeof(str2), " %s(%d) Killing Spree",kname,killerid);
    GameTextForAll(str2,4000,3);
    SendClientMessageToAll(LIGHTBLUE,str2);
    SetPlayerWantedLevel(killerid, 3);
    GivePlayerMoney(killerid,4000);
    }
    if(Four[killerid] == 4)
    {
    SetPlayerWantedLevel(killerid, 4);
    }
    if(Dominat[killerid] == 5)
    {
    new str2[128];
    new kname[MAX_PLAYER_NAME];
    GetPlayerName(killerid,kname,sizeof(kname));
    format(str2,sizeof(str2), " %s(%d) Dominating",kname,killerid);
    GameTextForAll(str2,4000,3);
    SendClientMessageToAll(LIGHTBLUE,str2);
    SetPlayerWantedLevel(killerid, 5);
    GivePlayerMoney(killerid,6000);
    }
    if(Six[killerid] == 6)
    {
    SetPlayerWantedLevel(killerid, 6);
    }
    if(Rampage[killerid] == 8)
    {
    new str2[128];
    new kname[MAX_PLAYER_NAME];
    GetPlayerName(killerid,kname,sizeof(kname));
    format(str2,sizeof(str2), " %s(%d) Rampage Killing",kname,killerid);
    GameTextForAll(str2,4000,3);
    SendClientMessageToAll(LIGHTBLUE,str2);
    SetPlayerWantedLevel(killerid, 6);
    GivePlayerMoney(killerid,8000);
    }

    if(Monster[killerid] == 12)
    {
    new str2[128];
    new kname[MAX_PLAYER_NAME];
    GetPlayerName(killerid,kname,sizeof(kname));
    format(str2,sizeof(str2), " %s(%d) Monster Killing",kname,killerid);
    GameTextForAll(str2,4000,3);
    SendClientMessageToAll(LIGHTBLUE,str2);
    SetPlayerWantedLevel(killerid, 6);
    GivePlayerMoney(killerid,10000);

    }
    return 1;

}


public OnPlayerText(playerid, text[])
{
    if(text[0] == '!')
    {
    new string[128];
    GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), "[Team Chat] %s: %s", string, text[1]);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
    }
    return 0;
    }

    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/shop", true))
    {
    SendClientMessage(playerid,0xff0010ff,"***Shop Disabled in This Mission***");
        return 1;
    }
    return SendClientMessage(playerid,COLOR_RED,"Unknown Command Use /help For All Commands");
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}
forward Score(playerid);
public Score(playerid)
{
    if(KillsRed > KillsBlue)
    {
    GameTextForAll("~r~Red ~w~Team Won~w~!!~n~ ~r~The Round ~w~+10000",3000,3);
    SetTimer("GameModeExitFunc",3000,0);
        for(new i;i<MAX_PLAYERS;i++)
        {
          if(gTeam[i] == TEAM_RED)
        {
        GivePlayerMoney(i,10000);
        }
        }
    TextDrawDestroy(Kills);
    }else if(KillsBlue > KillsRed)
    {
    GameTextForAll("~g~Blue ~w~Team Won~w~!!~n~ ~r~The Round ~w~+10000",3000,3);
    SetTimer("GameModeExitFunc",3000,0);
    TextDrawDestroy(Kills);

        for(new i;i<MAX_PLAYERS;i++)
        {
          if(gTeam[i] == TEAM_BlUE)
        {
        GivePlayerMoney(i,10000);
        }
        }
    }else if( KillsBlue == KillsRed && KillsRed == KillsBlue)
    {
    GameTextForAll("~w~Mission ~y~Draw~b~!",3000,3);
    SetTimer("GameModeExitFunc",3000,0);
    TextDrawDestroy(Kills);

    }
    return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
        new Team1, Team2;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && i != playerid)
        {
            if(gTeam[i] == TEAM_RED) Team1++;
            else if(gTeam[i] == TEAM_BlUE) Team2++;
        }
    }
    if(gTeam[playerid] == TEAM_RED && Team1 > Team2)
    {
        //SendClientMessage(playerid, 0xFFFFFFFF, "This team is full! Please Choose Another Team.");
        SetTimerEx("TeamFull", 100, false, "i", playerid);
        return 0;
    }
    else if(gTeam[playerid] == TEAM_BlUE && Team2 > Team1)
    {
        //SendClientMessage(playerid, 0xFFFFFFFF, "This team is full! Please Choose Another Team.");
        SetTimerEx("TeamFull", 100, false, "i", playerid);
        return 0;
    }

    if(gTeam[playerid] == TEAM_RED)
    {
    SetPlayerColor(playerid,COLOR_RED);
    } else if(gTeam[playerid] == TEAM_BlUE)
    {
    SetPlayerColor(playerid,COLOR_BLUE);
    }

       TextDrawShowForPlayer(playerid,Kills);

    return 1;
}
forward TeamFull(playerid);
public TeamFull(playerid)
{
    TextDrawShowForPlayer(playerid,Textdraw2);
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    SetTimerEx("TeamHide", 2000, 1, "i", playerid);


    return 1;
}
forward TeamHide(playerid);
public TeamHide(playerid)
{
    TextDrawHideForPlayer(playerid,Textdraw2);
    return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{   new
            playerScores[MAX_PLAYERS][rankingEnum],
            index
        ;
    for(new i; i != MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                playerScores[index][player_Score] = GetPlayerScore(i);
                playerScores[index++][player_ID] = i;
            }
        }
    GetPlayerHighestScores(playerScores, 0, index);

        new
            score_Text[256] = "~n~",
            player_Name[20]
        ;
    for(new i; i < 5; ++i)
        {
            if(i < index)
            {
                GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
            }
            else
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, i + 1);
        }
        TextDrawSetString(text_Top5[1], score_Text);



    return 1;
}
stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
    new
        tempLeft = left,
        tempRight = right,
        pivot = array[(left + right) / 2][player_Score],
        tempVar
    ;
    while(tempLeft <= tempRight)
    {
        while(array[tempLeft][player_Score] > pivot) tempLeft++;
        while(array[tempRight][player_Score] < pivot) tempRight--;

        if(tempLeft <= tempRight)
        {
            tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
            tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
            tempLeft++, tempRight--;
        }
    }
    if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
    if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}



public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

public GameModeExitFunc(playerid) {
    SendRconCommand("changemode ?");
    GameTextForAll("~y~Changing Game ~n~ ~w~Please Wait....",5000,1);
    for(new i;i<15;++i)
    {
        KillTimer(GameTimer);
        TextDrawShowForPlayer(playerid,Textdraw0);
        SendClientMessageToAll(COLOR_BLUE,"  ");
        TextDrawDestroy(text_Top5[0]);
        TextDrawDestroy(text_Top5[1]);
    }

     }
Reply


Messages In This Thread
[Ajuda] Simples - by kairos - 03.11.2011, 06:50
Re: Ajuda Simples - by CanTLoGin - 03.11.2011, 08:13
Re: Ajuda Simples - by PlueX - 03.11.2011, 08:14
Re: Ajuda Simples - by kairos - 03.11.2011, 10:44

Forum Jump:


Users browsing this thread: 1 Guest(s)