Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:buybiz(playerid,params[])
- {
- if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
- if(gPlayerLogged[playerid] != 0)
- {
- new Float:oldposx, Float:oldposy, Float:oldposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- new string[128],sendername[25],stringcasa[128];
- for(new b = 1; b < sizeof(++)
- {
- if(PlayerToPoint(2.0, playerid, BizzInfo[bEntranceX], BizzInfo[bEntranceY], BizzInfo[bEntranceZ]) && BizzInfo[bOwned] == 0)
- {
- if(PlayerInfo[playerid][pPbiskey] <= 254) return SendClientMessage(playerid, COLOR_WHITE, "{FFB870}You already own a business, type /sellbiztostate if you want to buy this one.");
- if(PlayerInfo[playerid][pLevel] < BizzInfo[bLevelNeeded])
- {
- format(string, sizeof(string), "{FFB870}You must be level %d to purchase this.",BizzInfo[bLevelNeeded]);
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- if(GetPlayerCash(playerid) > BizzInfo[bBuyPrice])
- {
- PlayerInfo[playerid][pPbiskey] = b;
- BizzInfo[bOwned] = 1;
- GetPlayerName(playerid, sendername, sizeof(sendername));
- strmid(BizzInfo[bOwner], PlayerInfo[playerid][pNormalName], 0, 25, 255);
- GivePlayerCash(playerid,-BizzInfo[bBuyPrice]);
- GameTextForPlayer(playerid, "~w~Welcome~n~You can exit at any time by moving to this door and press enter", 5000, 3);
- if(BizzInfo[bSbiz] == 0)
- {
- PlayerInfo[playerid][pInt] = BizzInfo[bInterior];
- PlayerInfo[playerid][pLocal] = b ;
- InBussines[playerid] = b;
- SetPlayerInterior(playerid,BizzInfo[bInterior]);
- SetPlayerVirtualWorld(playerid, BizzInfo[bVirtual]);
- PlayerInfo[playerid][pInt] = BizzInfo[bInterior];
- SetPlayerPosEx(playerid,BizzInfo[bExitX],BizzInfo[bExitY],BizzInfo[bExitZ]);
- }
- SendClientMessage(playerid, COLOR_WHITE, "Congratulations, On Your New Purchase.");
- SendClientMessage(playerid, COLOR_WHITE, "Type /help to review the new business help section.");
- format(stringcasa, sizeof(stringcasa), "%s [user:%d] a cumparat bizz-ul [bizz:%d] de la Stat pentru $%s.",sendername,PlayerInfo[playerid][pSQLID],b,FormatNumber(BizzInfo[bBuyPrice]));
- ABroadCast(COLOR_YELLOW, stringcasa,1);
- new var100[256],y,m,d,h,mi,s,string2[256],string3[256];
- getdate(y,m,d);
- gettime(h,mi,s);
- format(string2,sizeof(string2),"[%02d-%02d-%d %02d:%02d:%02d] %s[user:%d] bought bizz %d for $%s.",d,m,y,h,mi,s,sendername,PlayerInfo[playerid][pSQLID],b,FormatNumber(BizzInfo[bBuyPrice]));
- mysql_real_escape_string(string2, string3);
- mysql_format(SQL, var100, sizeof(var100), "INSERT INTO playerlogs (`playerid`,`giverid`,`action`,`time`) VALUES ('%d','0','%s','%02d-%02d-%d %02d:%02d:%02d')", PlayerInfo[playerid][pSQLID],string3,d,m,y,h,mi,s);
- mysql_tquery(SQL,var100,"","");
- new str1[256];
- mysql_format(SQL,str1,sizeof(str1),"UPDATE users SET `Money`='%d',`Bizz`='%d' WHERE `name`='%s'",GetPlayerCash(playerid),PlayerInfo[playerid][pPbiskey],PlayerInfo[playerid][pNormalName]);
- mysql_tquery(SQL,str1,"","");
- mysql_format(SQL,str1,sizeof(str1),"UPDATE `bizz` SET `Owned`='1',`Owner`='%s' WHERE `ID`='%d'",BizzInfo[bOwner],b);
- mysql_tquery(SQL,str1,"","");
- OnPropTextdrawUpdate(2,b);
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_WHITE, "You don't have the cash for that");
- return 1;
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement