rob Script help
#1

Im trying to figure out how to add if the person begins a robbery, and they leave the business it will cancel the robbery. Would this go under Playerstatecahnge or Keystatechange on exit business or under my on player exitbiz? here should be all the necessary code to help me out thanks!

pawn Код:
forward RobStore(playerid);
forward RobPorn(playerid);
forward RobHardware(playerid);
forward RobSmoke(playerid);
forward RobLiquor(playerid);
forward RobFood(playerid);
forward OnPlayerExitBusiness(playerid,bizid);

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
if(newkeys == KEY_YES)
    {

        //****ENTER****

        new house = GetClosestHouse(playerid);
        if(house > -1 && in_house[playerid] == -1 && GetPlayerVirtualWorld(playerid) == 0)
        {

            if(HouseInfo[house][hLocked]) { GameTextForPlayer(playerid,"~r~Locked",5000,6); PlayerPlaySound(playerid,1145,0.0,0.0,0.0); return 1; }
            SetPlayerInterior(playerid,HouseInfo[house][hInterior]);
            SetPlayerVirtualWorld(playerid,house);
            SetPlayerPos(playerid,HouseInfo[house][hInteriorX],HouseInfo[house][hInteriorY],HouseInfo[house][hInteriorZ]);
            in_house[playerid] = house;
            return 1;

        }

        new biz = GetClosestBiz(playerid);
        if(biz > -1 && GetPlayerVirtualWorld(playerid) == 0)
        {

            if(!BizInfo[biz][bOpen]) { GameTextForPlayer(playerid,"~r~Closed",5000,6); PlayerPlaySound(playerid,1145,0.0,0.0,0.0); return 1; }
            OnPlayerEnterBusiness(playerid,biz);
            return 1;

        }

        new inter = GetClosestInterior(playerid);
        if(inter > -1 && GetPlayerVirtualWorld(playerid) == 0)
        {

            OnPlayerEnterInterior(playerid,inter);
            return 1;

        }

        //****EXIT****

        house = in_house[playerid];
        if(house > -1)
        {

            if(HouseInfo[house][hLocked]) { GameTextForPlayer(playerid,"~r~Locked",5000,6); PlayerPlaySound(playerid,1145,0.0,0.0,0.0); return 1; }
            SetPlayerPos(playerid,HouseInfo[house][hSpawnX],HouseInfo[house][hSpawnY],HouseInfo[house][hSpawnZ]);
            SetPlayerInterior(playerid,0);
            SetPlayerVirtualWorld(playerid,0);
            in_house[playerid] = -1;
            return 1;

        }

        biz = in_biz[playerid];
        if(biz > -1)
        {

            OnPlayerExitBusiness(playerid,biz);
            return 1;

        }

        OnPlayerExitInterior(playerid);
        return 1;

    }
    return 1;
}

public OnPlayerExitBusiness(playerid,bizid)
{

    if(!tutorial_stage[playerid])
    {
        switch(BizInfo[bizid][bType])
        {

            case BIZ_TYPE_LOCO:
            {

                in_biz[playerid] = -1;
                if(IsPlayerInAnyVehicle(playerid))
                {

                    in_modshop[playerid] = 0;
                    new id = GetPlayerVehicleID(playerid);
                    SetVehiclePosEx(id,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                    SetPlayerVirtualWorld(playerid,0);
                    SetVehicleVirtualWorld(id,0);
                    FormatModString(id);

                }
                else
                {

                    SetPlayerPos(playerid,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);

                }

            }
            case BIZ_TYPE_WHEELS:
            {

                in_biz[playerid] = -1;
                if(IsPlayerInAnyVehicle(playerid))
                {

                    in_modshop[playerid] = 0;
                    new id = GetPlayerVehicleID(playerid);
                    SetVehiclePosEx(id,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                    SetPlayerVirtualWorld(playerid,0);
                    SetVehicleVirtualWorld(id,0);
                    FormatModString(id);

                }
                else
                {

                    SetPlayerPos(playerid,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);

                }

            }
            case BIZ_TYPE_TRANS:
            {

                in_biz[playerid] = -1;
                if(IsPlayerInAnyVehicle(playerid))
                {

                    in_modshop[playerid] = 0;
                    new id = GetPlayerVehicleID(playerid);
                    SetVehiclePosEx(id,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                    SetPlayerVirtualWorld(playerid,0);
                    SetVehicleVirtualWorld(id,0);
                    FormatModString(id);

                }
                else
                {

                    SetPlayerPos(playerid,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);

                }

            }
            case BIZ_TYPE_VEHICLE:
            {

                if(donator_vehicle_purchasing[playerid] == -1)
                {

                    vehicle_showroom_position[playerid] = -1;
                    carchoose_color[playerid] = 0;
                    in_biz[playerid] = -1;
                    SetPlayerPos(playerid,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                    SetPlayerVirtualWorld(playerid,0);
                    SetCameraBehindPlayer(playerid);
                    vehicle_showroom_position[playerid] = -1;
                    vehicle_showroom_type[playerid] = -1;
                    TogglePlayerControllable(playerid,1);
                    TextDrawHideForPlayer(playerid,infotxt[playerid]);

                 }
                 else
                 {

                    SendClientMessage(playerid,COLOR_LIGHTRED,"Please wait until your vehicle has finished purchasing.");

                 }

            }
            case BIZ_TYPE_BOAT:
            {

                in_biz[playerid] = -1;
                SetPlayerPos(playerid,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                SetPlayerVirtualWorld(playerid,0);
                SetCameraBehindPlayer(playerid);
                vehicle_showroom_position[playerid] = -1;
                vehicle_showroom_type[playerid] = -1;
                TogglePlayerControllable(playerid,1);
                TextDrawHideForPlayer(playerid,infotxt[playerid]);

            }
            case BIZ_TYPE_PLANE:
            {

                in_biz[playerid] = -1;
                SetPlayerPos(playerid,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                SetPlayerVirtualWorld(playerid,0);
                SetCameraBehindPlayer(playerid);
                vehicle_showroom_position[playerid] = -1;
                vehicle_showroom_type[playerid] = -1;
                TogglePlayerControllable(playerid,1);
                TextDrawHideForPlayer(playerid,infotxt[playerid]);

            }
            default:
            {

                if(IsPlayerInRangeOfPoint(playerid,10.0,BizInfo[bizid][bInteriorX],BizInfo[bizid][bInteriorY],BizInfo[bizid][bInteriorZ]) && GetPlayerVirtualWorld(playerid) == (bizid + 2000))
                {

                    if(IsPlayerInAnyVehicle(playerid) && AccountInfo[playerid][aAdmin] >= ADMIN_LVL_ADMIN)
                    {

                        new veh = GetPlayerVehicleID(playerid);
                        SetVehiclePosEx(veh,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                        LinkVehicleToInterior(veh,0);
                        SetPlayerInterior(playerid,0);
                        in_biz[playerid] = -1;
                        if(BizInfo[bizid][bType] == BIZ_TYPE_DRINK && strlen(BizInfo[bizid][bStream]))
                        {

                            StopAudioStreamForPlayer(playerid);

                        }

                    }
                    else
                    {

                        SetPlayerPos(playerid,BizInfo[bizid][bSpawnX],BizInfo[bizid][bSpawnY],BizInfo[bizid][bSpawnZ]);
                        SetPlayerInterior(playerid,0);
                        SetPlayerVirtualWorld(playerid,0);
                        SetCameraBehindPlayer(playerid);
                        in_biz[playerid] = -1;
                        if(BizInfo[bizid][bType] == BIZ_TYPE_DRINK && strlen(BizInfo[bizid][bStream]))
                        {

                            StopAudioStreamForPlayer(playerid);

                        }

                    }

                }
            }
        }
    }
}

COMMAND:rob(playerid, params[])
{
    if(HasCooldown(playerid,COOLDOWN_ROB)) { SendMsg(playerid,COLOR_LIGHTRED,"Please wait another %d seconds before doing this command",GetCooldownLevel(playerid,COOLDOWN_ROB)); return 1; }
    if(GetPlayerWeapon(playerid) > 21 || GetPlayerWeapon(playerid) < 32)
    {

        new biz = GetClosestBiz(playerid);
        if(biz == -1) { biz = in_biz[playerid]; }
        if(biz > -1)
        {

            if(BizInfo[biz][bBank] > 0)
            {
                if(IsInStore(playerid))
                {
                    new robtime;
                    robtime = randomEx(45000,90000);
                    SetTimerEx("RobStore",robtime,false,"i",playerid);
                    ApplyAnimation(playerid,"PED","gang_gunstand",4.0,0,1,1,0,robtime,1);
                    SendClientMessage(playerid,COLOR_RED,"You have started robbing this store.");
                    return 1;
                }
                if(IsInPornShop(playerid))
                {
                    new robtime;
                    robtime = randomEx(15000,45000);
                    SetTimerEx("RobStore",robtime,false,"i",playerid);
                    ApplyAnimation(playerid,"PED","gang_gunstand",4.0,0,1,1,0,robtime,1);
                    SendClientMessage(playerid,COLOR_RED,"You have started robbing this store.");
                    return 1;
                }
                if(IsInHardware(playerid))
                {
                    new robtime;
                    robtime = randomEx(10000,40000);
                    SetTimerEx("RobStore",robtime,false,"i",playerid);
                    ApplyAnimation(playerid,"PED","gang_gunstand",4.0,0,1,1,0,robtime,1);
                    SendClientMessage(playerid,COLOR_RED,"You have started robbing this store.");
                    return 1;
                }
                if(IsInSmoke(playerid))
                {
                    new robtime;
                    robtime = randomEx(7500,25000);
                    SetTimerEx("RobStore",robtime,false,"i",playerid);
                    ApplyAnimation(playerid,"PED","gang_gunstand",4.0,0,1,1,0,robtime,1);
                    SendClientMessage(playerid,COLOR_RED,"You have started robbing this store.");
                    return 1;
                }
                if(IsInLiquor(playerid))
                {
                    new robtime;
                    robtime = randomEx(13000,20000);
                    SetTimerEx("RobStore",robtime,false,"i",playerid);
                    ApplyAnimation(playerid,"PED","gang_gunstand",4.0,0,1,1,0,robtime,1);
                    SendClientMessage(playerid,COLOR_RED,"You have started robbing this store.");
                    return 1;
                }
                if(IsInFood(playerid))
                {
                    new robtime;
                    robtime = randomEx(15000,45000);
                    SetTimerEx("RobStore",robtime,false,"i",playerid);
                    ApplyAnimation(playerid,"PED","gang_gunstand",4.0,0,1,1,0,robtime,1);
                    SendClientMessage(playerid,COLOR_RED,"You have started robbing this store.");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid,COLOR_WHITE,"This business has no money.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED,"You are not in a store.");
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You do not have a weapon.");
        return 1;
    }
    return 1;
}
public RobFood(playerid)
{
    new biz = GetClosestBiz(playerid);
    new loot = randomEx(400,800);
    SendMoney(playerid,loot);
    TakeBizMoney(biz,loot);
    SetCooldown(playerid,COOLDOWN_ROB,30);
    return 1;
}
public RobLiquor(playerid)
{
    new biz = GetClosestBiz(playerid);
    new loot = randomEx(175,350);
    SendMoney(playerid,loot);
    TakeBizMoney(biz,loot);
    SetCooldown(playerid,COOLDOWN_ROB,30);
    return 1;
}
public RobSmoke(playerid)
{
    new biz = GetClosestBiz(playerid);
    new loot = randomEx(75,125);
    SendMoney(playerid,loot);
    TakeBizMoney(biz,loot);
    SetCooldown(playerid,COOLDOWN_ROB,30);
    return 1;
}
public RobHardware(playerid)
{
    new biz = GetClosestBiz(playerid);
    new loot = randomEx(75,175);
    SendMoney(playerid,loot);
    TakeBizMoney(biz,loot);
    SetCooldown(playerid,COOLDOWN_ROB,30);
    return 1;
}
public RobPorn(playerid)
{
    new biz = GetClosestBiz(playerid);
    new loot = randomEx(125,250);
    SendMoney(playerid,loot);
    TakeBizMoney(biz,loot);
    SetCooldown(playerid,COOLDOWN_ROB,30);
    return 1;
}

public RobStore(playerid)
{
    new biz = GetClosestBiz(playerid);
    new loot = randomEx(700,1001);
    SendMoney(playerid,loot);
    TakeBizMoney(biz,loot);
    SetCooldown(playerid,COOLDOWN_ROB,30);
    return 1;
}
stock randomEx(min,max)
{
    return min + random ( max - min );
}
Reply
#2

public OnPlayerLeaveCheckpoint(playerid)
Reply
#3

coul dyou please ellabrorate when the player rob they are not in a checkpoint. so how would this prevent the rob from happening
Reply
#4

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
if(newinterior == 0)
{
your code
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)