[Tutorial] Simple Money Bags Event System
#1

Hey guys, today im going to teach you how to make simple Money Bags event system. Mainly, this is great feature for your TDM Server, DM Server, or even Free roam, and RP Server. So, when admin type /moneybags location(location to tell player, which the Money Bags located). So Lets Get started!

First, i assumed you to get Include commands like zcmd or something. And you gotta need sscanf include too. And, you gotta need streamer plugin too.

Ok, if you have thoose includes/plugins, So lets started.

First, we need to define Variables that check if Money Bags event already started or not!. So, type following code:
pawn Код:
new MoneyBags[MAX_PLAYERS];
.
pawn Код:
new MoneyPickup;
pawn Код:
OnPlayerConnect(playerid)
{
MoneyBags[playerid] = 0;
return 1;
}
Okay, let me explain what i did there. First of all, like ive explained above, We created a variable to check is the Money Bags Event already started or not! And we created a variable "MoneyPickup" for making a Money Pickup which we gonna use later. And we setted, OnPlayerConnect, callback which when player is connected, we setted MoneyBags[playerid] = 0; . That Means, when player is connected, moneybag event is not started yet! . We gotta change the value to 1, when we have typed a command later which gonna started a Money Bags Event. Ok, now lets move to making the commands shall we?

Ok type the following code:

pawn Код:
CMD:moneybags(playerid, params[])
{
new location[128];
new str[128];
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "youre not admin");
return 1;
}

Okay first we checked, if normal player(not rcon login admin type /moneybags when he is in Game) then, we returned a message that, that player is not admin. Which only admin who able start the event!
And almost forget explain it ( :P) , new location is the variable that we gotta use later, to tell everyone, where will the moneybags located. Okay type following code under thoose codes:

pawn Код:
if(sscanf(params,"s",location))return SendClientMessage(playerid, -1, "usage /moneybags location"
Ok that means, when we typed example /moneybags 10 , the event will not started, and will return a message like above. this is a simple using in sscanf.

pawn Код:
if(MoneyBags[playerid] == 1)return SendClientMessage(playerid, -1, "you already used that event");
Ok, that means, when we are already type /moneybags commands, and type it again, it will return a error message.

And, if above situtation are not there, then we gotta type as follows:

pawn Код:
new Float:p[3];
    GetPlayerPos(playerid, p[0], p[1], p[2]);
    MoneyPickup = CreateDynamicPickup(1274, 2, p[0]+10, p[1], p[2], -1, -1, -1, 100.0);
    format(str,sizeof(str),"Admin has started, and putted moneybag around : %s",location);
    SendClientMessageToAll(COLOR_ORANGE, str);
    MoneyBags[playerid] = 1;
Okay, first we make a variable to get the player position. And once an admin type /moneybags, and have found a good location to put the money bags pickup, it will be make a money pickup automotically, based on his location. Also, we setted MoneyBags[playerid] = 1; for checking that Money bags event has been started!.

Okay, now lets move on!

Add following code:
pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
        if(pickupid == MoneyPickup)
        {
            new str[128];
            new Name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Name, sizeof(Name));
            format(str,sizeof(str),"%s(ID:%d)has founded the hided Money!!!!",Name,playerid);
            SendClientMessageToAll(COLOR_GREEN,str);
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(gTeam[playerid] == gTeam[i])
                {
                    new str2[128];
                    GivePlayerMoney(i, 25000);
                    format(str2,sizeof(str),"%s(ID:%d)has found the hided money. You got 25000$for it!",Name,playerid);
                    SendClientMessage(i,COLOR_GREEN,str);
                }
            }
            MoneyBags[playerid] = 0;
            DestroyDynamicPickup(MoneyPickup);
        }
        return 1;
}
First, we make a string variable, and Name Variable to get player Name (A player that found a money bag that hided!. And sendclientmessage to all player, that someone has found the money Bags that hided!.
And then in that loop, we checked, if Player team as same as with player team that found money bag, the all of player team that found a money bag, will get that money too, and send to all Teams member, that player from your team has been found A Money Bag!. And also, when player has pickup the hided money, we setted the variable MoneyBags to 0. That means, the event has been ended! And we also do DestroyDynamicPickup to destroy the pickup of hided Money.


Okay we have done now!. Please comment for my tutorial
I asked appologize if i did mistake for my above tutorial!

Thanks
Reply
#2

Oh come on guys, No comments here?
Reply
#3

Good But need more explanation about everything how everything is going if it's for nowbies...

And good first tutorial gradz anyway

7/10
Reply
#4

Thanks

yeah im not like that good in explaining
Reply
#5

nice thx <3
Reply
#6

Won't work, I still don't understand why Money bags array was used. You set the admin's var to 1 and the one who picks it up to 0, so will return error the 2nd time. You don't need an array, a global var is okay.
Reply
#7

Nice, +rep keep it up.
Reply
#8

very good

Reply
#9

you have to explain more where to put each script
Reply
#10

you just steal another MB SCRIPT ..http://forum.sa-mp.com/showthread.ph...Moneybag+Event
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)