[GameMode] Hide The Case
#1

Hi! I made a cool GameMode, this mode is a 'hide and seek' game, simply a player hides the case and the other players may search for it. It contains a little account-system using dini and a level system. Its very usable for events or to play with your friends.

Thanks to Incognation for his very cool locations!

(uses sccanf2 and dudb);
pawn Код:
/*
    'Hide The Case' game mode

    © Casss

*/


#include <a_samp>
#include <dudb>
#include <sscanf2>

#pragma unused strtok

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_GREEN 0x008000FF
enum pLevelsEnum
{
    pLevelName[128],
    pLevelInt
};
new pLevels[][pLevelsEnum]=
{
    {"Citynoob", 0},
    {"New Newbie", 1},
    {"Newbie", 2},
    {"Old Newbie", 3},
    {"Almost A Finder", 5},
    {"Finder", 10},
    {"Good Finder", 20},
    {"Super Finder", 30},
    {"Ultra Finder", 60},
    {"The Godfinder", 100}
};

new Float:GamePos[][3]=
{
    {-2357.4312,2869.7793,46.9325},
    {307.2526,2726.2410,28.0562},
    {84.3819,1853.1613,17.6406},
    {-126.6899,2257.7703,28.3452},
    {1269.7426,-804.5637,88.3151},
    {655.8994,-565.0873,16.3359},
    {-2315.3838,-2141.4878,56.1676},
    {-1386.8198,-2017.2813,-0.3589},
    {-2415.3025,-268.5521,35.6166},
    {-1460.7621,489.5605,3.0414},
    {-686.0491,966.8251,12.1328},
    {-310.1288,1569.0444,75.3594},
    {2481.0266,1525.6437,11.7737},
    {2854.3823,909.1571,10.7500},
    {2521.3306,-1273.0709,34.8898},
    {2497.0088,-855.0878,94.6913}
};

new HideTurn;
new KillWarns[MAX_PLAYERS];
new GameON;
new Participating[MAX_PLAYERS];
new game;
new CPickup;
new GCount;
new GTimer;
new Text:pLevel[MAX_PLAYERS];
new GameHided = 0;
new HideTurnColor;

forward GameCountDown();


new Float:CaseX,Float:CaseY,Float:CaseZ;

main()
{
    print("\nHide the case (© Cas van Leijden/Casss)");
    print("A new 'Hide the case' game must be started by an admin in-game!");
}

public OnGameModeInit()
{


    SetGameModeText("Hide the case - © Casss");
   
    for(new i=0;i<299;i++)
    {
        if(!IsInvalidSkin(i))
        {
            AddPlayerClass(i, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
        }
    }
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        pLevel[i] = TextDrawCreate(638.000000, 437.000000, "~y~INFO: ~w~Please /login or /register");
        TextDrawAlignment(pLevel[i], 3);
        TextDrawBackgroundColor(pLevel[i], 255);
        TextDrawFont(pLevel[i], 1);
        TextDrawLetterSize(pLevel[i], 0.389999, 1.000000);
        TextDrawColor(pLevel[i], -1);
        TextDrawSetOutline(pLevel[i], 0);
        TextDrawSetProportional(pLevel[i], 1);
        TextDrawSetShadow(pLevel[i], 1);
        TextDrawUseBox(pLevel[i], 1);
        TextDrawBoxColor(pLevel[i], 119);


    }
    return 1;
}

public OnGameModeExit()
{
    print("\nHide the case game-mode was stopped!");
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 2323.7124,1283.2646,97.6171);
    SetPlayerCameraPos(playerid, 2323.8889,1288.4949,96.6513);
    SetPlayerCameraLookAt(playerid, 2323.7124,1283.2646,97.6171);
    SetPlayerFacingAngle( playerid, 0 );
    return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid,COLOR_YELLOW,"INFO: {AFAFAF}Welcome to Hide the case, please choose a playerskin!");
    TextDrawShowForPlayer(playerid,pLevel[playerid]);
   
    new pName[MAX_PLAYER_NAME];
    new jMSG[512];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(jMSG,sizeof(jMSG),"INFO: {AFAFAF}%s has joined the game", pName);
   
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i))
        {
            if(i != playerid)
            {
                SendClientMessage(i, COLOR_GREEN, jMSG);
            }
        }
    }
   
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Participating[playerid] = 0;
    if(playerid == HideTurn)
    {
        SendClientMessageToAll(COLOR_YELLOW,"INFO: {AFAFAF}The player who had to hide the case left. So the next player may hide the case!");
        StopGame();
    }
    TextDrawSetString(pLevel[playerid],"~y~INFO: ~w~Please /login or /register");
    new pName[256];
    GetPlayerName(playerid,pName,sizeof(pName));
    dini_IntSet(udb_encode(pName),"Money",GetPlayerMoney(playerid));
    dini_IntSet(udb_encode(pName),"Score",GetPVarInt(playerid,"Score"));
    dini_IntSet(udb_encode(pName),"ALevel",GetPVarInt(playerid,"ALevel"));
    SetPVarInt(playerid,"Score",0);
    SetPVarInt(playerid,"ALevel",0);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(GameON == 1 && Participating[playerid] == 0)
    {
        GameTextForPlayer(playerid,"~w~WAIT FOR NEXT ROUND TO SPAWN!",5000,6);
    }

    else if(GameON == 1 && Participating[playerid] == 1)
    {
        SetPlayerPos(playerid,GamePos[game][0],GamePos[game][1],GamePos[game][2]);
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    KillWarns[killerid] += 1;


    new NoKillMSG[128];
    format(NoKillMSG,sizeof(NoKillMSG), "WARNING: {AFAFAF}DO NOT KILL! (%d/3)", KillWarns[killerid]);
    SendClientMessage(killerid,COLOR_RED,NoKillMSG);
   
    if(KillWarns[killerid] == 3)
    {
        SendClientMessage(killerid,COLOR_RED,"WARNING: {AFAFAF}You have been kicked for killing...");
        Kick(killerid);
    }
    return 1;
}



public OnPlayerCommandText(playerid, cmdtext[])
{

    dcmd(hidecase, 8, cmdtext);
    dcmd(newgame, 7, cmdtext);
    dcmd(stopgame, 8, cmdtext);
    dcmd(changepass, 10, cmdtext);
    dcmd(register,8, cmdtext);
    dcmd(login, 5, cmdtext);
    dcmd(help, 4, cmdtext);

   

    return 0;
}

dcmd_help(playerid,params[])
{

    if(!strcmp(params,"register", false))
    {
        SendClientMessage(playerid, COLOR_YELLOW,"INFO: {AFAFAF}Use /register <password> to register a account, with an account your stats wil be saved and much more");
        return 1;
    }
    else if(strcmp(params,"login", false))
    {
        SendClientMessage(playerid, COLOR_YELLOW,"INFO: {AFAFAF}Use /login <password> to login to your account which you can register with /register <password>");
        return 1;
    }
    else if(strcmp(params,"changepass", false))
    {
        SendClientMessage(playerid,COLOR_YELLOW, "INFO: {AFAFAF}Use /changepass <new password> to change your the password of your account which you can make with /register <password>");
        return 1;
    }
    else if(strcmp(params,"help", false))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "INFO: {AFAFAF}/help Shows the help");
        return 1;
    }
    else if(strcmp(params,"hidecase", false))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "INFO: {AFAFAF}In a 'Hide The Case' game, use /hidecase to hide the case (if its your turn to hide the case.)");
        return 1;
    }
    SendClientMessage(playerid, COLOR_YELLOW,"USE: {AFAFAF}/help <command>");
    SendClientMessage(playerid, COLOR_YELLOW,"INFO: {AFAFAF}Commands: register login changepass help hidecase");
    return 1;
}

dcmd_hidecase(playerid,params[])
{
        if(playerid == HideTurn)
        {
            if(GameHided != 1)
            {
                #pragma unused params
                new Float:x,Float:y,Float:z;
                GetPlayerPos(playerid,x,y,z);
                CaseX = x; CaseY = y; CaseZ = z;
                StartGame();
                GameHided = 1;
                return 1;
            }
            SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}You may not hide the case again during a game!");
            return 1;
        }
        SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}It is not your turn to hide the case!");
        return 1;
}




dcmd_newgame(playerid, params[])
{
    #pragma unused params
    if(IsPlayerAdmin(playerid) == 1)
    {
        SendClientMessageToAll(COLOR_YELLOW,"INFO: {AFAFAF}New Hide the case game started!");
        StartGameHide();
        GameON = 1;

       
    }
    return 1;
}

dcmd_stopgame(playerid, params[])
{
    #pragma unused params
    if(IsPlayerAdmin(playerid) == 1)
    {
        StopGame();
        SendClientMessageToAll(COLOR_YELLOW,"INFO: {AFAFAF}Hide the case game stopped!");
    }
}

dcmd_register(playerid, params[])
{
    if(strlen(params))
    {
        new pName[256];
        GetPlayerName(playerid,pName,sizeof(pName));
        if(dini_Exists(udb_encode(pName)) == 0)
        {
       
            dini_Create(udb_encode(pName));
            dini_Set(udb_encode(pName),"Password",udb_encode(params));
            dini_IntSet(udb_encode(pName),"Money",GetPlayerMoney(playerid));
            dini_IntSet(udb_encode(pName),"Score",0);
            dini_IntSet(udb_encode(pName),"ALevel",0);
           
            SetPVarInt(playerid,"Score", 0);
            SendClientMessage(playerid,COLOR_GREEN,"SUCCES: {AFAFAF}Account registered succesfully, use /login <password> to login!");
            return 1;

        }
        SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}Account does already exists!");
        return 1;
    }
    SendClientMessage(playerid,COLOR_YELLOW,"USE: {AFAFAF}/register <password>");
    return 1;
}

dcmd_login(playerid, params[])
{
    if(strlen(params))
    {
        new pName[256];
        new pMoney, pScore;
        GetPlayerName(playerid,pName,sizeof(pName));
        if(GetPVarInt(playerid, "Logged") == 1)
        {
            SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}You are already logged in!");
            return 1;
        }
        if(dini_Exists(udb_encode(pName)) == 1)
        {
            if(!strcmp(udb_encode(params),dini_Get(udb_encode(pName),"Password"),true))
            {
                pMoney = GetPlayerMoney(playerid);
                pScore = GetPlayerScore(playerid);
           
                SetPlayerMoney(playerid, pMoney + dini_Int(udb_encode(pName),"Money"));
                SetPlayerScore(playerid, pScore + dini_Int(udb_encode(pName),"Score"));
               
                SetPVarInt(playerid,"Score",dini_Int(udb_encode(pName),"Score"));
                SetPVarInt(playerid,"ALevel",dini_Int(udb_encode(pName),"Level"));
               
                SendClientMessage(playerid, COLOR_GREEN, "SUCCES:{AFAFAF} You are now logged in!");
               
                SetPVarInt(playerid,"Logged",1);
               
                new pLevelMSG[256];
                switch(GetPVarInt(playerid,"Score"))
                {
                    case 0: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",0,pLevels[0][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 1: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",1,pLevels[1][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 2: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",2,pLevels[2][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 3: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",3,pLevels[3][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 5: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",4,pLevels[4][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 10: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",5,pLevels[5][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 20: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",6,pLevels[6][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 30: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",7,pLevels[7][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 60: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",8,pLevels[8][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 100: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",9,pLevels[9][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                }


               
                return 1;
            }
            SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}Wrong password!");
            return 1;
        }
        SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}Account does not exist!");
        return 1;
    }
    SendClientMessage(playerid,COLOR_YELLOW,"USE: {AFAFAF}/login <password>");
    return 1;
}

dcmd_changepass(playerid, params[])
{
    if(strlen(params))
    {
        if(GetPVarInt(playerid, "Logged") == 0)
        {
            SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}You are not logged in!");
            return 1;
        }
        new pName[512];
        GetPlayerName(playerid,pName,sizeof(pName));
        dini_Set(udb_encode(pName),"Password",udb_encode(params));
        SendClientMessage(playerid,COLOR_GREEN,"SUCCES: {AFAFAF}New password set!");
        return 1;
    }
    SendClientMessage(playerid,COLOR_YELLOW,"USE: {AFAFAF}/changepass");
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
        if(pickupid == CPickup)
        {
            if(playerid != HideTurn)
            {
                new pName[128], FoundSTR[512];
                GetPlayerName(playerid,pName,sizeof(pName));
                format(FoundSTR,sizeof(FoundSTR),"SUCCES: {AFAFAF}%s has found the case!",pName);
                SendClientMessageToAll(COLOR_GREEN,FoundSTR);
                SendClientMessageToAll(COLOR_GREY,"Next round will be started in 5 seconds...");
                GCount = 5;
                GTimer = SetTimer("GameCountDown",1000,true);
                HideTurn += 1;
                GameHided = 0;
                DestroyPickup(CPickup);
                new ScoreInt = GetPVarInt(playerid,"Score");
               
                SetPVarInt(playerid,"Score",ScoreInt+1);
                SetPlayerScore(playerid,GetPVarInt(playerid,"Score"));
               
                new pLevelMSG[128];
                switch(GetPVarInt(playerid,"Score"))
                {
                    case 0: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",0,pLevels[0][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 1: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",1,pLevels[1][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 2: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",2,pLevels[2][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 3: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",3,pLevels[3][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 5: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",4,pLevels[4][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 10: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",5,pLevels[5][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 20: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",6,pLevels[6][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 30: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",7,pLevels[7][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 60: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",8,pLevels[8][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                    case 100: { format(pLevelMSG,sizeof(pLevelMSG),"~g~LEVEL %d: ~w~%s",9,pLevels[9][pLevelName]); TextDrawSetString(pLevel[playerid],pLevelMSG); }
                }
                return 1;
        }
            SendClientMessage(playerid,COLOR_RED,"WARNING: {AFAFAF}You may not pick up the case you hided!");
       
            return 1;
    }
       


        return 1;
}


stock StartGameHide()
{

    game = random(sizeof(GamePos));
    SetPlayerInterior(HideTurn,0);
    if(IsPlayerConnected(HideTurn))
    {
        SetPlayerWorldBounds(HideTurn, GamePos[game][0]+100.0, GamePos[game][1]+100.0, GamePos[game][2]+100.0, -50.0);
        SetPlayerPos(HideTurn,GamePos[game][0],GamePos[game][1],GamePos[game][2]);
        HideTurnColor = GetPlayerColor(HideTurn);
        SetPlayerColor(HideTurn,0000000000);
       
        SendClientMessage(HideTurn,COLOR_YELLOW,"INFO: {AFAFAF}You need to hide the case! Use /hidecase to hide it!");
        return 1;
    }
    else
    {
        if(HideTurn >= MAX_PLAYERS)
        {
            HideTurn = 0;
        }
        else
        {
            HideTurn +=1;
        }
        StartGameHide();
        return 0;
    }


}

stock StartGame()
{
    SetPlayerColor(HideTurn, HideTurnColor);
    for(new i;i<MAX_PLAYERS;i++)
    {
        SetPlayerInterior(i,0);
        SetPlayerWorldBounds(i, GamePos[game][0]+100.0, GamePos[game][1]+100.0, GamePos[game][2]+100.0, -50.0);
        SetPlayerPos(i,GamePos[game][0],GamePos[game][1],GamePos[game][2]);
       
       
        Participating[i] = 1;
        if(i == HideTurn)
        {
            SendClientMessage(i,COLOR_YELLOW,"INFO: {AFAFAF}Please do not search for the case you hided, as the hider you cant pick it up anyway.");
        }
        else
        {
            SendClientMessage(i,COLOR_YELLOW,"INFO: {AFAFAF}You may now search for the case!");
        }
    }
    CPickup = CreatePickup(1210, 1, CaseX, CaseY, CaseZ, -1);
    return 1;
}

stock StopGame()
{
    HideTurn = 0;
    game = 0;
    GameON = 0;
    GameHided = 0;
    for(new i;i<MAX_PLAYERS;i++)
    {
        Participating[i] = 0;
        SetPlayerWorldBounds(i, 20000.0000, -20000.0000, 20000.0000, -20000.0000);
        SpawnPlayer(i);
    }
    return 1;
}

public GameCountDown()
{
    if(GCount == 0)
    {
        StartGameHide();
        KillTimer(GTimer);
    }
    else
    {
        new GString[256];
        format(GString,sizeof(GString),"~w~Next round in ~g~%d ~w~seconds!",GCount);
        GameTextForAll(GString,1000,5);
        GCount -= 1;
    }
    return 1;
}


IsInvalidSkin(skinid)
{
    switch(skinid)
    {
        case 3, 4, 5, 6, 8, 42, 65, 74, 86,
            119, 149, 208, 265, 266, 267,
            268, 269, 270, 271, 272, 273, 289, 300: return 1;
    }
    return 0;
}
Usage:
/login (Login Command)
/register (Register Command)
/changepass (Change Password Command)
/hidecase (Hide the case)
/newgame (Start a new game, if a game is running first use /stopgame)
/stopgame (Stop a game)
/help (Help Command)
Reply
#2

Look's nice.
Reply
#3

I have install it but what are the commands ?
Reply
#4

Commands:

Quote:
Originally Posted by Casss
Посмотреть сообщение
Usage:
/login (Login Command)
/register (Register Command)
/changepass (Change Password Command)
/hidecase (Hide the case)
/newgame (Start a new game, if a game is running first use /stopgame)
/stopgame (Stop a game)
/help (Help Command)
Reply
#5

Nice work!
Reply
#6

hmm but it would be great if its a FS
Reply
#7

Quote:
Originally Posted by Dark_Thunder
Посмотреть сообщение
hmm but it would be great if its a FS
True, but i made it for an event. :P
Reply
#8

Quote:
Originally Posted by Dark_Thunder
Посмотреть сообщение
hmm but it would be great if its a FS
Very easy to make it into an FS.
Reply
#9

Quote:
Originally Posted by Mike Garber
Посмотреть сообщение
Very easy to make it into an FS.
mmm, for me it's like a minigame

@Casss: it's very good !
Reply
#10

Cool! Nice and unique

-J
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)