Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <sscanf2>
- #define MAX_ADS 15
- enum Ads
- {
- Sub[20],
- Advert[128],
- Placeby[24],
- };
- new AdsInfo[MAX_ADS][Ads];
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- 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);
- LoadAds();
- 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 OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/ads", cmdtext, true, 10) == 0)
- {
- ShowPlayerDialog(playerid,1, DIALOG_STYLE_INPUT, "Subject", "Subject Enter Ads:", "Login", "Cancel");
- return 1;
- }
- if (strcmp("/sads", cmdtext, true, 10) == 0)
- {
- SaveAds();
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(response)
- {
- if(!strlen(inputtext)) return SendClientMessage(playerid, 1, "ERROR: You must enter something!");
- if(strlen(inputtext) > 19) return SendClientMessage(playerid, 1, "ERROR: 20 Greater");
- MoveAds();
- AdsInfo[0][Sub] = strval(inputtext);
- ShowPlayerDialog(playerid,2, DIALOG_STYLE_INPUT, "ADS", "Enter Ads:", "Login", "Cancel");
- }
- }
- if(dialogid == 2)
- {
- if(response)
- {
- new name[MAX_PLAYERS];
- if(!strlen(inputtext)) return SendClientMessage(playerid, 1, "ERROR: You must enter something!");
- if(strlen(inputtext) > 66) return SendClientMessage(playerid, 1, "ERROR: 66 Greater");
- AdsInfo[0][Advert] = strval(inputtext);
- GetPlayerName(playerid, name, sizeof(name));
- AdsInfo[0][Placeby] = strval(name);
- }
- }
- return 1;
- }
- LoadAds()
- {
- if(!fexist("Ads.cfg")) return 1;
- new
- szFileStr[512],
- iIndex,
- File: iFileHandle = fopen("Ads.cfg", io_read);
- while (iIndex < sizeof(AdsInfo) && fread(iFileHandle, szFileStr)) {
- sscanf(szFileStr, "p<|>s[20]s[128]s[24]",
- AdsInfo[iIndex][Sub],
- AdsInfo[iIndex][Advert],
- AdsInfo[iIndex][Placeby]
- );
- ++iIndex;
- }
- return fclose(iFileHandle);
- }
- SaveAds()
- {
- new idx;
- new File: file2;
- while (idx < sizeof(AdsInfo))
- {
- new coordsstring[512];
- format(coordsstring, sizeof(coordsstring), "%s|%s|%s\n",
- AdsInfo[idx][Sub],
- AdsInfo[idx][Advert],
- AdsInfo[idx][Placeby]);
- if(idx == 0)
- {
- file2 = fopen("Ads.cfg", io_write);
- }else
- {
- file2 = fopen("Ads.cfg", io_append);
- }
- fwrite(file2, coordsstring);
- idx++;
- fclose(file2);
- }
- return 1;
- }
- MoveAds(){
- new Subs[20], Adve[128], Placer[24],iIndex;
- while (iIndex < 15){
- Subs = strval(AdsInfo[iIndex][Sub]);
- Adve = strval(AdsInfo[iIndex][Advert]);
- Placer = strval(AdsInfo[iIndex][Placeby]);
- ++iIndex;
- AdsInfo[iIndex][Sub] = strval(Subs);
- AdsInfo[iIndex][Advert] = strval(Adve);
- AdsInfo[iIndex][Placeby] = strval(Placer);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment