// Busineses [ mic_biz ]

/*
native AddStaticBiz(Float:x,Float:y,Float:z,Float:ix,Float:iy,Float:iz,ii);
native SetBizCost(bizid,cost);
native GetBizInfo(bizid,info[],value[]);
native SetBizInfo(bizid,info[],value[]);
native SetPlayerInBiz(playerid,bizid);
native SetPlayerOutBiz(playerid,bizid);
native IsPlayerAllowedInBiz(playerid,bizid);
*/

public GetBizInfo(bizid,info[],value[])
{
new str[100];
new ret;
format(str,100,"biz%d",bizid);
ret = LoadProperty(str,info,value);
return ret;
}


public SetBizInfo(bizid,info[],value[]){
new str[100];
format(str,100,"biz%d",bizid);
SaveProperty(str,info,value);
}

public AddStaticBiz(Float:x,Float:y,Float:z,Float:ix,Float:iy,Float:iz,ii){
bid++;
BP[CreatePickup(1272,2,x,y,z)] = bid;
BIX[bid] = ix;
BIY[bid] = iy;
BIZ[bid] = iz;
BII[bid] = ii;
BOX[bid] = x;
BOY[bid] = y;
BOZ[bid] = z;
new str[256];
format(str,256,"Biz%d.zip",bid);
if (!fexist(str)){
new File:Biz = fopen(str,io_write);
fclose(Biz);
SetBizInfo(bid,"Owner","none");
SetBizInfo(bid,"Fee","0");
SetBizInfo(bid,"Cost","50000");
}
return bid;
}

public OnPlayerPickUpPickup(playerid,pickupid){
CallLocalFunction("onplayerpickuppickup","ii",playerid,pickupid);

if (pickupid == gym1){
TogglePlayerControllable(playerid,0);
SetPlayerPos(playerid,773.5598,-2.2508,1000.7257);
SetPlayerFacingAngle(playerid,178.9851);
SetCameraBehindPlayer(playerid);
GameTextForPlayer(playerid,"~n~~n~~n~~n~Press ~g~ENTER~w~ to start~n~Press ~r~SPACE~w~ to stop",3000,5);
gymt1 = SetTimer("IsInGym1",500,1);
}


if(BP[pickupid] != 0){OnPlayerEnterBizz(playerid,BP[pickupid]);}
else if(HP[pickupid] != 0){
//print("OnPlayerEnterHousee");

OnPlayerEnterHousee(playerid,HP[pickupid]);}
}

public OnPlayerEnterBizz(playerid,bizid){
ShowMenuForPlayer(Bmenu,playerid);
BID[playerid] = bizid;
}

public SetPlayerInBiz(playerid,bizid){
PIB[playerid] = bizid;
SetPlayerPos(playerid,BIX[bizid],BIY[bizid],BIZ[bizid]);
SetPlayerInterior(playerid,BII[bizid]);
ShowMenuForPlayer(Bexit,playerid);
CallLocalFunction("OnPlayerEnterBiz","ii",playerid,bizid);
new str3[100],str2[256];
format(str3,100,"biz%d",bizid);
LoadProperty(str3,"Fee",str2);
new cost = strval(str2);
GivePlayerMoney(playerid,-cost);
}

public SetPlayerOutBiz(playerid,bizid){
PIB[playerid] = 0;
SetPlayerPos(playerid,BOX[bizid],BOY[bizid],BOZ[bizid]);
SetPlayerInterior(playerid,0);
CallLocalFunction("OnPlayerLeaveBiz","ii",playerid,bizid);
}

public IsPlayerAllowedInBiz(playerid,bizid){
new str[256];
GetBizInfo(PIB[playerid],"Fee",str);
new mon = strval(str);
if (GetPlayerMoney(playerid) >= mon){
return 1;
}
else{
return 0;
}
}



