Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Business system by [BG][NCS]Abaddon
- */
- #include <a_samp>
- #include <sscanf2>
- #include <dini>
- #define FILTERSCRIPT
- #if defined FILTERSCRIPT
- new bizid=0;
- new serverinfo[1000];
- #define DIALOG_BUY 12
- #define DIALOG_ENTER 13
- public OnFilterScriptInit()
- {
- format(serverinfo,sizeof(serverinfo),"/sInfo.ini");
- if(!dini_Exists(serverinfo))
- {
- dini_Create(serverinfo);
- dini_Set(serverinfo,"BizIds","0");
- }
- else
- {
- bizid = dini_Int(serverinfo,"BizIds");
- LoadBizz(bizid);
- }
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- #define MAX_BIZZS 200
- enum bInfo
- {
- bOwner[MAX_PLAYER_NAME],
- bool:bOwned,
- bType,
- bPrice,
- bPayOut,
- Float:bXcoord,
- Float:bYcoord,
- Float:bZcoord,
- bLocked,
- bPickUp
- }
- new BizInfo[MAX_BIZZS][bInfo];
- stock GetName(playerid)
- {
- new pname[MAX_PLAYER_NAME]; pname="Íåâàëèäíî ID íà èãðà÷.";
- if(IsPlayerConnected(playerid)) {
- GetPlayerName(playerid, pname, sizeof (pname));
- }
- return pname;
- }
- stock LoadBizz()
- {
- new biz[256];
- for(new b=0;b<bizid+1;b++)
- {
- format(biz,sizeof(biz),"/%d.ini",b);
- format(BizInfo[b][bOwner],MAX_PLAYERS,"%s",dini_Get(biz,"Owner"));
- BizInfo[b][bOwned] = dini_Bool(biz,"Owned");
- BizInfo[b][bType] = dini_Int(biz,"Type");
- BizInfo[b][bPrice] = dini_Int(biz,"Price");
- BizInfo[b][bPayOut] = dini_Int(biz,"PayOut");
- BizInfo[b][bXcoord] = dini_Float(biz,"Xcoord");
- BizInfo[b][bYcoord] = dini_Float(biz,"Ycoord");
- BizInfo[b][bZcoord] = dini_Float(biz,"Zcoord");
- BizInfo[b][bLocked] = dini_Bool(biz,"Locked");
- BizInfo[b][bPickUp] = CreatePickup(1272, 1, BizInfo[b][bXcoord],BizInfo[b][bYcoord],BizInfo[b][bZcoord], -1);
- }
- return 1;
- }
- stock LoadEBizz(b)
- {
- new biz[256];
- format(biz,sizeof(biz),"/%d.ini",b);
- format(BizInfo[b][bOwner],MAX_PLAYERS,"%s",dini_Get(biz,"Owner"));
- BizInfo[b][bOwned] = dini_Bool(biz,"Owned");
- BizInfo[b][bType] = dini_Int(biz,"Type");
- BizInfo[b][bPrice] = dini_Int(biz,"Price");
- BizInfo[b][bPayOut] = dini_Int(biz,"PayOut");
- BizInfo[b][bXcoord] = dini_Float(biz,"Xcoord");
- BizInfo[b][bYcoord] = dini_Float(biz,"Ycoord");
- BizInfo[b][bZcoord] = dini_Float(biz,"Zcoord");
- BizInfo[b][bLocked] = dini_Bool(biz,"Locked");
- BizInfo[b][bPickUp] = CreatePickup(1272, 1, BizInfo[b][bXcoord],BizInfo[b][bYcoord],BizInfo[b][bZcoord], -1);
- return 1;
- }
- stock SaveEBiz(b)
- {
- new biz[256];
- format(biz,sizeof(biz),"/%d.ini",b);
- dini_Set(biz,"Owner",BizInfo[b][bOwner]);
- dini_BoolSet(biz,"Owned",BizInfo[b][bOwned]);
- dini_IntSet(biz,"Type",BizInfo[b][bType]);
- dini_IntSet(biz,"Price",BizInfo[b][bPrice]);
- dini_IntSet(biz,"PayOut",BizInfo[b][bPayOut]);
- dini_FloatSet(biz,"Xcoord",BizInfo[b][bXcoord]);
- dini_FloatSet(biz,"Ycoord",BizInfo[b][bYcoord]);
- dini_FloatSet(biz,"Zcoord",BizInfo[b][bZcoord]);
- dini_BoolSet(biz,"Locked",BizInfo[b][bLocked]);
- return 1;
- }
- stock BizType(b)
- {
- new type[30];
- switch(BizInfo[b][bType])
- {
- case 1: type = "Êëóá";
- case 2: type = "Áàð";
- case 3: type = "Ìàãàçèí çà îðúæèÿ";
- }
- return type;
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[128], idx;
- cmd = strtok(cmdtext, idx);
- new tmp[128];
- new string[2000];
- new params[256];
- sscanf(cmdtext, "s[28]S()[100]", cmd, params);
- if(strcmp(cmd,"/createbiz",true)==0)
- {
- new type,price,payout;
- new Float:pX,Float:pY,Float:pZ;
- if(sscanf(params,"iii",type,price,payout)) return SendClientMessage(playerid,-1,"Èçïîëçâàé: /createbizz [type][price][payout]");
- bizid += 1;
- GetPlayerPos(playerid,pX,pY,pZ);
- new biz[256];
- format(biz,sizeof(biz),"Businesses/%d.ini",bizid);
- if(!dini_Exists(biz))
- {
- dini_Create(biz);
- dini_Set(biz,"Owner","Íÿìà");
- dini_BoolSet(biz,"Owned",0);
- dini_IntSet(biz,"Type",type);
- dini_IntSet(biz,"Price",price);
- dini_IntSet(biz,"PayOut",payout);
- dini_FloatSet(biz,"Xcoord",pX);
- dini_FloatSet(biz,"Ycoord",pY);
- dini_FloatSet(biz,"Zcoord",pZ);
- dini_BoolSet(biz,"Locked",0);
- LoadEBizz(bizid);
- }
- SendClientMessage(playerid,-1,"Bizz has been created");
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- for(new b=0;b<bizid+1;b++)
- {
- if(pickupid == BizInfo[b][bPickUp])
- {
- if(BizInfo[b][bOwned] == 0)
- {
- new string[2000];
- format(string,sizeof(string),"Ñîáñòâåíèê: %s\nÑòîéíîñò: %s\nÇàïëàùàíå: %s\nÂèä íà áèçíåñ: %s\nID: %d",BizInfo[b][bOwner],BizInfo[b][bPrice],BizInfo[b][bPayOut],BizType(b),b);
- ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,"Áèçíåñ:",string,"Êóïè","Îòêàç");
- }
- else
- {
- new string[2000];
- format(string,sizeof(string),"Ñîáñòâåíèê: %s\nÑòîéíîñò: %s\nÇàïëàùàíå: %s\nÂèä íà áèçíåñ: %s\nID: %d",BizInfo[b][bOwner],BizInfo[b][bPrice],BizInfo[b][bPayOut],BizType(b),b);
- ShowPlayerDialog(playerid,DIALOG_ENTER,DIALOG_STYLE_MSGBOX,"Áèçíåñ:",string,"Âëåç","Îòêàç");
- }
- }
- }
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_BUY)
- {
- for(new b=0;b<bizid+1;b++)
- {
- if(response)
- {
- if(IsPlayerInRangeOfPoint(playerid,2.0,BizInfo[b][bXcoord],BizInfo[b][bYcoord],BizInfo[b][bZcoord]))
- {
- if(GetPlayerMoney(playerid) >= BizInfo[b][bPrice])
- {
- GivePlayerMoney(playerid, -BizInfo[b][bPrice]);
- format(BizInfo[b][bOwner],MAX_PLAYERS,"%s",GetName(playerid));
- BizInfo[b][bOwned] = 1;
- SaveEBiz(b);
- LoadEBizz(b);
- }
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment