[Tutorial] How To Create Simple Robatm System
#1

Hello SA-MP Forum and All scripters there , i want make tutorial
Simple RobAtm System , and how it works
If you /robatm you will wait for a sec for rob the atm
you will get money from the ATM
and you will rob able again with timer
sorry for my bad english
================================================== ==========
Its for variable will make timer for robbing and giveplayer money
you cant edit the money what you want
pawn Code:
new Robatm[MAX_PLAYERS]; // Add This At Top Bottom your define
#define COLOR_WHITE 0xFFFFFFAA //This for the colour

forward RobAtm(playerid);
public RobAtm(playerid)
{
    if(GetPlayerWeapon(playerid) == 0) GivePlayerCash(playerid,500); //It Will Give 500$ If You Holding Weapon ID's 0
    if(GetPlayerWeapon(playerid) == 22) GivePlayerCash(playerid,700); // Same Like Top
    if(GetPlayerWeapon(playerid) == 23) GivePlayerCash(playerid,1000);
    if(GetPlayerWeapon(playerid) == 24) GivePlayerCash(playerid,1500);
    if(GetPlayerWeapon(playerid) == 25) GivePlayerCash(playerid,1700);
    if(GetPlayerWeapon(playerid) == 26) GivePlayerCash(playerid,2000);
    if(GetPlayerWeapon(playerid) == 27) GivePlayerCash(playerid,2500);
    if(GetPlayerWeapon(playerid) == 28) GivePlayerCash(playerid,2700);
    if(GetPlayerWeapon(playerid) == 29) GivePlayerCash(playerid,3500);
    if(GetPlayerWeapon(playerid) == 30) GivePlayerCash(playerid,3700);
    if(GetPlayerWeapon(playerid) == 31) GivePlayerCash(playerid,4000);
    if(GetPlayerWeapon(playerid) == 32) GivePlayerCash(playerid,4500);
    if(GetPlayerWeapon(playerid) == 33) GivePlayerCash(playerid,4700);
    if(GetPlayerWeapon(playerid) == 34) GivePlayerCash(playerid,5000);
    if(GetPlayerWeapon(playerid) == 35) GivePlayerCash(playerid,5500);
    if(GetPlayerWeapon(playerid) == 36) GivePlayerCash(playerid,10000);
    SendClientMessage(playerid, COLOR_WHITE, "You Rob the Atm and now have 6 wanted level!");
    WantedPoints[playerid] = 6; // Your Variable Wanted
    SetPlayerWantedLevel(playerid, 6);
    PlayerInfo[playerid][pWantedLevel] = 6; // Your Variable Wanted
    TogglePlayerControllable(playerid,1);
    return 1;
}
its will create timer for make ATM is rob able again
pawn Code:
//This Timer For Make Robatm Able Again
forward after7(playerid);
public after7(playerid)
{
    Robatm[playerid] = 0;
    SendClientMessage(playerid, COLOR_WHITE, "   You can rob atm again!");
    return 1;
}
And this the command for robbing the ATM
pawn Code:
CMD:robatm(playerid, params[])
{
    if(!IsAtATM(playerid)) // You Can Change This To Your Own Coordinat
    {
        SendClientMessage(playerid, COLOR_WHITE, "   You are not at ATM !!");
        return 1;
    }
    if (Robatm[playerid] == 0 )
    {
        SendClientMessage(playerid, COLOR_WHITE, "You now robbing !!!");
        Robatm[playerid] = 1;
        SendCopMessage(COLOR_WHITE, "Stranger: Help someone trying to rob ATM!"); //It Will Send Cop Message if you have faction , you cant delete it if you not want to use it
        SetTimerEx("RobAtm", 10000, false, "i", playerid); // It for robbing timer
        SetTimerEx("after7", 15*60*1000, false, "i", playerid); // it for make robbing able again
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "[Info:]You Are Not At ATM !");
    }
    return 1;
}
All In One

pawn Code:
new Robatm[MAX_PLAYERS]; // Add This At Top Bottom your define
#define COLOR_WHITE 0xFFFFFFAA //This for the colour

forward RobAtm(playerid);
public RobAtm(playerid)
{
    if(GetPlayerWeapon(playerid) == 0) GivePlayerCash(playerid,500); //It Will Give 500$ If You Holding Weapon ID's 0
    if(GetPlayerWeapon(playerid) == 22) GivePlayerCash(playerid,700); // Same Like Top
    if(GetPlayerWeapon(playerid) == 23) GivePlayerCash(playerid,1000);
    if(GetPlayerWeapon(playerid) == 24) GivePlayerCash(playerid,1500);
    if(GetPlayerWeapon(playerid) == 25) GivePlayerCash(playerid,1700);
    if(GetPlayerWeapon(playerid) == 26) GivePlayerCash(playerid,2000);
    if(GetPlayerWeapon(playerid) == 27) GivePlayerCash(playerid,2500);
    if(GetPlayerWeapon(playerid) == 28) GivePlayerCash(playerid,2700);
    if(GetPlayerWeapon(playerid) == 29) GivePlayerCash(playerid,3500);
    if(GetPlayerWeapon(playerid) == 30) GivePlayerCash(playerid,3700);
    if(GetPlayerWeapon(playerid) == 31) GivePlayerCash(playerid,4000);
    if(GetPlayerWeapon(playerid) == 32) GivePlayerCash(playerid,4500);
    if(GetPlayerWeapon(playerid) == 33) GivePlayerCash(playerid,4700);
    if(GetPlayerWeapon(playerid) == 34) GivePlayerCash(playerid,5000);
    if(GetPlayerWeapon(playerid) == 35) GivePlayerCash(playerid,5500);
    if(GetPlayerWeapon(playerid) == 36) GivePlayerCash(playerid,10000);
    SendClientMessage(playerid, COLOR_WHITE, "You Rob the Atm and now have 6 wanted level!");
    WantedPoints[playerid] = 6; // Your Variable Wanted
    SetPlayerWantedLevel(playerid, 6);
    PlayerInfo[playerid][pWantedLevel] = 6; // Your Variable Wanted
    TogglePlayerControllable(playerid,1);
    return 1;
}

//This Timer For Make Robatm Able Again
forward after7(playerid);
public after7(playerid)
{
    Robatm[playerid] = 0;
    SendClientMessage(playerid, COLOR_WHITE, "   You can rob atm again!");
    return 1;
}

CMD:robatm(playerid, params[])
{
    if(!IsAtATM(playerid)) // You Can Change This To Your Own Coordinat
    {
        SendClientMessage(playerid, COLOR_WHITE, "   You are not at ATM !!");
        return 1;
    }
    if (Robatm[playerid] == 0 )
    {
        SendClientMessage(playerid, COLOR_WHITE, "You now robbing !!!");
        Robatm[playerid] = 1;
        SendCopMessage(COLOR_WHITE, "Stranger: Help someone trying to rob ATM!"); //It Will Send Cop Message if you have faction , you cant delete it if you not want to use it
        SetTimerEx("RobAtm", 10000, false, "i", playerid); // It for robbing timer
        SetTimerEx("after7", 15*60*1000, false, "i", playerid); // it for make robbing able again
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "[Info:]You Are Not At ATM !");
    }
    return 1;
}
You Need Edit Your Own Variables ,
GivePlayerCash mean GivePlayerMoney
you can change it to your variable , sorry for my bad english hope you like it
Reply
#2

Horribly explained...
Reply
#3

Quote:
Originally Posted by FireCat
View Post
Horribly explained...
lol iam indonesian , sorry if i have a bad english xD
Reply
#4

You could simply do something like this.
pawn Code:
new
    PlayerWeaponID = GetPlayerWeapon(playerid)
;

switch(PlayerWeaponID)
{
    case 0: return  GivePlayerCash(playerid, Amount);
    case 22 .. 36: return  GivePlayerCash(playerid, Amount);
}
Instead of this long code
pawn Code:
if(GetPlayerWeapon(playerid) == 0) GivePlayerCash(playerid,500); //It Will Give 500$ If You Holding Weapon ID's 0
if(GetPlayerWeapon(playerid) == 22) GivePlayerCash(playerid,700); // Same Like Top
if(GetPlayerWeapon(playerid) == 23) GivePlayerCash(playerid,1000);
if(GetPlayerWeapon(playerid) == 24) GivePlayerCash(playerid,1500);
if(GetPlayerWeapon(playerid) == 25) GivePlayerCash(playerid,1700);
if(GetPlayerWeapon(playerid) == 26) GivePlayerCash(playerid,2000);
if(GetPlayerWeapon(playerid) == 27) GivePlayerCash(playerid,2500);
if(GetPlayerWeapon(playerid) == 28) GivePlayerCash(playerid,2700);
if(GetPlayerWeapon(playerid) == 29) GivePlayerCash(playerid,3500);
if(GetPlayerWeapon(playerid) == 30) GivePlayerCash(playerid,3700);
if(GetPlayerWeapon(playerid) == 31) GivePlayerCash(playerid,4000);
if(GetPlayerWeapon(playerid) == 32) GivePlayerCash(playerid,4500);
if(GetPlayerWeapon(playerid) == 33) GivePlayerCash(playerid,4700);
if(GetPlayerWeapon(playerid) == 34) GivePlayerCash(playerid,5000);
if(GetPlayerWeapon(playerid) == 35) GivePlayerCash(playerid,5500);
if(GetPlayerWeapon(playerid) == 36) GivePlayerCash(playerid,10000);
Reply
#5

Quote:
Originally Posted by pds2k12
View Post
You could simply do something like this.
pawn Code:
new
    PlayerWeaponID = GetPlayerWeapon(playerid)
;

switch(PlayerWeaponID)
{
    case 0: return  GivePlayerCash(playerid, Amount);
    case 22 .. 36: return  GivePlayerCash(playerid, Amount);
}
Instead of this long code
pawn Code:
if(GetPlayerWeapon(playerid) == 0) GivePlayerCash(playerid,500); //It Will Give 500$ If You Holding Weapon ID's 0
if(GetPlayerWeapon(playerid) == 22) GivePlayerCash(playerid,700); // Same Like Top
if(GetPlayerWeapon(playerid) == 23) GivePlayerCash(playerid,1000);
if(GetPlayerWeapon(playerid) == 24) GivePlayerCash(playerid,1500);
if(GetPlayerWeapon(playerid) == 25) GivePlayerCash(playerid,1700);
if(GetPlayerWeapon(playerid) == 26) GivePlayerCash(playerid,2000);
if(GetPlayerWeapon(playerid) == 27) GivePlayerCash(playerid,2500);
if(GetPlayerWeapon(playerid) == 28) GivePlayerCash(playerid,2700);
if(GetPlayerWeapon(playerid) == 29) GivePlayerCash(playerid,3500);
if(GetPlayerWeapon(playerid) == 30) GivePlayerCash(playerid,3700);
if(GetPlayerWeapon(playerid) == 31) GivePlayerCash(playerid,4000);
if(GetPlayerWeapon(playerid) == 32) GivePlayerCash(playerid,4500);
if(GetPlayerWeapon(playerid) == 33) GivePlayerCash(playerid,4700);
if(GetPlayerWeapon(playerid) == 34) GivePlayerCash(playerid,5000);
if(GetPlayerWeapon(playerid) == 35) GivePlayerCash(playerid,5500);
if(GetPlayerWeapon(playerid) == 36) GivePlayerCash(playerid,10000);
Okey , thanks for your suggestion ,
Reply
#6

Quote:
Originally Posted by pds2k12
View Post
You could simply do something like this.
pawn Code:
new
    PlayerWeaponID = GetPlayerWeapon(playerid)
;

switch(PlayerWeaponID)
{
    case 0: return  GivePlayerCash(playerid, Amount);
    case 22 .. 36: return  GivePlayerCash(playerid, Amount);
}
Instead of this long code
pawn Code:
if(GetPlayerWeapon(playerid) == 0) GivePlayerCash(playerid,500); //It Will Give 500$ If You Holding Weapon ID's 0
if(GetPlayerWeapon(playerid) == 22) GivePlayerCash(playerid,700); // Same Like Top
if(GetPlayerWeapon(playerid) == 23) GivePlayerCash(playerid,1000);
if(GetPlayerWeapon(playerid) == 24) GivePlayerCash(playerid,1500);
if(GetPlayerWeapon(playerid) == 25) GivePlayerCash(playerid,1700);
if(GetPlayerWeapon(playerid) == 26) GivePlayerCash(playerid,2000);
if(GetPlayerWeapon(playerid) == 27) GivePlayerCash(playerid,2500);
if(GetPlayerWeapon(playerid) == 28) GivePlayerCash(playerid,2700);
if(GetPlayerWeapon(playerid) == 29) GivePlayerCash(playerid,3500);
if(GetPlayerWeapon(playerid) == 30) GivePlayerCash(playerid,3700);
if(GetPlayerWeapon(playerid) == 31) GivePlayerCash(playerid,4000);
if(GetPlayerWeapon(playerid) == 32) GivePlayerCash(playerid,4500);
if(GetPlayerWeapon(playerid) == 33) GivePlayerCash(playerid,4700);
if(GetPlayerWeapon(playerid) == 34) GivePlayerCash(playerid,5000);
if(GetPlayerWeapon(playerid) == 35) GivePlayerCash(playerid,5500);
if(GetPlayerWeapon(playerid) == 36) GivePlayerCash(playerid,10000);
but the amount of money was different if you use

case 22 .. 36: return GivePlayerCash(playerid, 10000);

all weapons we use will have same of amounts yet ?
Reply
#7

What pds2k12 showed should be more for you than just a suggestion. Every single one of those if statements will be evalated, and the GetPlayerWeapon will get called every single time. At least store it in a variable
Reply
#8

Quote:
Originally Posted by tandytanz
View Post
but the amount of money was different if you use

case 22 .. 36: return GivePlayerCash(playerid, 10000);

all weapons we use will have same of amounts yet ?
yes its mean case 22 - 36 will giveplayercash(playerid, amount);
only one amount
Reply
#9

you can't give money to the player that depends on what weapon is he holding, this causes a scam in the server
Reply
#10

Quote:
Originally Posted by AnonScripter
View Post
you can't give money to the player that depends on what weapon is he holding, this causes a scam in the server
lol it works perfectly on my server , you can try
Reply
#11

Quote:
Originally Posted by HolyScripter
View Post
lol it works perfectly on my server , you can try
i know that it's working, but i meant that it's not a great idea to give money to players in this method, use random money to avoid scamming
Reply
#12

Quote:
Originally Posted by HolyScripter
View Post
lol it works perfectly on my server , you can try
i didn't say it's not working, i said it's scamming
Reply
#13

Quote:
Originally Posted by AnonScripter
View Post
i didn't say it's not working, i said it's scamming
okey , free for suggestion , i use this on my server no bugs , working nicely cmiiw
Reply
#14

Ever heard of timestamps? USE THEM!
Reply
#15

good job man its works
Reply
#16

Quote:
Originally Posted by tboysamp
View Post
good job man its works
absolutely hahaha , thanks man
Reply
#17

Ho ho ho

Nice scripts,

I can use this script on my server


<< Januar Vaynard !
Reply
#18

Quote:
Originally Posted by Januar
View Post
Ho ho ho

Nice scripts,

I can use this script on my server


<< Januar Vaynard !
thanks man
Reply
#19

Copy + Paste is terrible

Code:
WantedPoints[playerid] = 6; // Same here 

SetPlayerWantedLevel(playerid, 6);

PlayerInfo[playerid][pWantedLevel] = 6; // Maybe I want to use pInfo not PlayerInfo and thie enum is not declared
Reply
#20

Keep it up
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)