Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //======================== [ Diretivas ] =======================================
- #include <a_samp>
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_BLUE 0x3FCFFFFF
- //======================== [ Arrays ] =======================================
- new
- bool:bHost[MAX_PLAYERS],
- iVagas,HotelCarros[10],
- sString[128]
- ;
- //======================== [ CallBacks ] =======================================
- main()
- {
- print("FS de hotel Simples ");
- print(" Criado [iPs]-GooGle- , [iPs]Knife e [iPs]Drakon ");
- }
- public OnFilterScriptInit()
- {
- AddStaticPickup(1239,1,2217.3179,-1146.5724,1025.7969,15);
- Create3DTextLabel("Aqui você pode se Hospedar ou Deshospedar !",COLOR_BLUE,2217.3179,-1146.5724,1025.7969,15, 0, 50);
- Create3DTextLabel("Hotel\nBem Vindo ao Hotel",COLOR_BLUE,2233.1387,-1159.7736,25.8906,15, 0, 50);
- Create3DTextLabel("Saida\nTenha um bom dia",COLOR_BLUE,2213.9690,-1150.4792,1025.7969,15, 0, 50);
- HotelCarros[0] = AddStaticVehicleEx(405,2228.01367188,-1156.13513184,25.81377029,88.83996582,-1,-1,50000000);
- HotelCarros[1] = AddStaticVehicleEx(405,2228.14086914,-1162.83337402,25.76814461,90.08544922,-1,-1,50000000);
- HotelCarros[2] = AddStaticVehicleEx(580,2216.77172852,-1170.51770020,25.63408661,269.64501953,-1,-1,50000000);
- HotelCarros[3] = AddStaticVehicleEx(580,2216.83642578,-1161.66687012,25.63408661,269.64501953,-1,-1,50000000);
- HotelCarros[4] = AddStaticVehicleEx(461,2206.31713867,-1176.70751953,25.40106392,269.90997314,-1,-1,50000000);
- HotelCarros[5] = AddStaticVehicleEx(461,2206.44824219,-1168.98254395,25.40106392,269.90661621,-1,-1,50000000);
- HotelCarros[6] = AddStaticVehicleEx(418,2206.32299805,-1161.00585938,25.91304779,270.09997559,-1,-1,50000000);
- HotelCarros[7] = AddStaticVehicleEx(418,2206.13183594,-1153.24804688,25.91304779,270.09887695,-1,-1,50000000);
- HotelCarros[8] = AddStaticVehicleEx(530,2227.93554688,-1170.24182129,25.52664757,90.54504395,-1,-1,50000000);
- HotelCarros[9] = AddStaticVehicleEx(530,2227.87255859,-1177.13598633,25.52664757,90.54382324,-1,-1,50000000);
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- Checar(playerid);
- return true;
- }
- public OnPlayerDisconnect(playerid,reason)
- {
- Salvar(playerid);
- return true;
- }
- public OnPlayerCommandText( playerid, cmdtext[])
- {
- if (!strcmp(cmdtext, "/deshospedar", true)) {
- if(bHost[playerid] == false)
- return SendClientMessage(playerid,COLOR_GREEN,"Você já está deshospedadado");
- --iVagas;
- bHost[playerid] = false;
- SendClientMessage(playerid,COLOR_GREEN,"Você se deshospedou, hotel agradece sua visita");
- return true;
- }
- if (!strcmp(cmdtext, "/hospedar", true)) {
- if(IsPlayerInRangeOfPoint(playerid, 10.0, 2217.3179,-1146.5724,1025.7969)) {
- if(bHost[playerid] == true)
- return SendClientMessage(playerid,COLOR_GREEN,"Você já está hospedadado");
- if(iVagas == 15)
- return SendClientMessage(playerid,COLOR_GREEN,"Já estamos com lotação maxima");
- iVagas++;
- SetPlayerInterior(playerid, 15);
- bHost[playerid] = true;
- Salvar(playerid);
- SpawnPlayer(playerid);
- format(sString,sizeof(sString),"Você ocupou a vaga %d/15 do hotel",iVagas);
- SendClientMessage(playerid,COLOR_GREEN,"Você pagou uma tarifa de 2000 reais para se hospedar");
- SendClientMessage(playerid,COLOR_GREEN,sString);
- }
- return true;
- }
- if (!strcmp(cmdtext, "/entrar", true)) {
- if(IsPlayerInRangeOfPoint(playerid,10.0,2233.1387,-1159.7736,25.8906)) {
- GameTextForPlayer(playerid, "~p~Hotel", 5000, 1);
- SetPlayerPos(playerid,2213.9690,-1150.4792,1025.7969);
- SetPlayerInterior(playerid,15);
- }
- if(IsPlayerInRangeOfPoint(playerid,10.0,2213.9690,-1150.4792,1025.7969)) {
- GameTextForPlayer(playerid, "~p~Los Santos", 5000, 1);
- SetPlayerPos(playerid,2233.1387,-1159.7736,25.8906);
- SetPlayerInterior(playerid,0);
- }
- return true;
- }
- return false;
- }
- public OnPlayerSpawn(playerid)
- {
- if(bHost[playerid] == false) {
- SetPlayerPos(playerid,2233.1387,-1159.7736,25.8906);
- }
- else {
- SetPlayerPos(playerid, 2235.1589,-1158.9023,1029.7969);
- SetPlayerInterior(playerid,15);
- }
- return true;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- new iVehicle = GetPlayerVehicleID(playerid);
- if(newstate == PLAYER_STATE_DRIVER) {
- for(new iLoop; iLoop != sizeof HotelCarros; ++iLoop) {
- if(bHost[playerid] == false && iVehicle == HotelCarros[iLoop]) {
- SendClientMessage(playerid,COLOR_GREEN,"Você não é um hospede do hotel.");
- RemovePlayerFromVehicle(playerid);
- TogglePlayerControllable(playerid, 1);
- break;
- }
- }
- }
- return true;
- }
- //======================== [ Funcões ] =========================================
- stock GetPlayerNick(iPlayer)
- {
- new sName[24];
- GetPlayerName(iPlayer,sName,24);
- return sName;
- }
- stock Salvar(iPlayer)
- {
- format (sString,64,"%s.ini",GetPlayerNick(iPlayer));
- if(fexist(sString)) {
- Fini_OpenFile(sString);
- Fini_SetBool("bHost",bHost[iPlayer]);
- Fini_SaveFile();
- Fini_CloseFile();
- }
- return true;
- }
- stock Checar(iPlayer)
- {
- format(sString,64,"%s.ini",GetPlayerNick(iPlayer));
- if(fexist(sString)) {
- Fini_OpenFile(sString);
- if(Fini_GetBool("bHost") == 0) bHost[iPlayer] = false;
- if(Fini_GetBool("bHost") == 1) bHost[iPlayer] = true;
- Fini_CloseFile();
- }
- return true;
- }
- //======================== [ Fini File ] =======================================
- #define maxtag (00244)
- #define maxfile (99999)
- #define maxname (00064)
- #define Fini_Exists fexist
- #define Fini_GetFloat(%0) floatstr(Fini_GetStr(%0))
- static
- zNormal1,
- fStr[maxtag],
- fTag[maxtag],
- fFile[maxfile],
- File:zFopenFile,
- fName[maxname],
- iSource
- ;
- stock
- Fini_OpenFile(fname[])
- {
- zFopenFile = fopen(fname,io_read);
- while(fread(zFopenFile,fStr))
- strins(fFile,fStr,strlen(fFile),maxfile);
- fclose(zFopenFile);
- format(fName,maxname,"%s",fname);
- return true;
- }
- stock
- Fini_SaveFile()
- {
- fremove(fName);
- zFopenFile = fopen(fName,io_write);
- fwrite(zFopenFile,fFile);
- fclose(zFopenFile);
- return true;
- }
- stock
- Fini_CloseFile()
- {
- fFile[0] = '\0';
- fName[0] = '\0';
- return true;
- }
- stock
- Fini_GetStr(ftag[])
- {
- format(fTag, maxtag, "%s=", ftag);
- iSource = strfind(fFile, fTag, false) + 1;
- strmid(fTag, fFile, iSource + strlen(fTag) - 1, strfind(fFile, "\n", false, iSource));
- return fTag;
- }
- stock Fini_SetStr(ftag[],fstr[])
- {
- format(fTag,maxtag, "%s=", ftag);
- zNormal1 = strfind(fFile,fTag, true);
- if(zNormal1 != -1)
- {
- strdel(fFile,zNormal1-1, strfind(fFile, "\n", false,zNormal1));
- format(fTag, sizeof(fTag), "%s=%s\r\n",ftag,fstr);
- strins(fFile, fTag, strlen(fFile));
- }
- else
- {
- format(fTag,maxtag, "%s=%s\r\n",ftag,fstr);
- strins(fFile,fTag, strlen(fFile));
- }
- return true;
- }
- stock
- Fini_Create(nFile[])
- {
- if (Fini_Exists(nFile)) return false;
- new File:cFile = fopen(nFile,io_write);
- return fclose(cFile);
- }
- stock
- Fini_SetVal(ftag[],fval)
- {
- static Seting[24];
- format(Seting,maxtag,"%d",fval);
- Fini_SetStr(ftag,Seting);
- return true;
- }
- stock
- Fini_SetFloat(ftag[],Float:fval)
- {
- static Seting[24];
- format(Seting,maxtag,"%f",fval);
- Fini_SetStr(ftag,Seting);
- return true;
- }
- stock
- Fini_SetBool(ftag[],bool:fval)
- {
- static Seting[24];
- format(Seting,maxtag,"%d",fval);
- Fini_SetStr(ftag,Seting);
- return true;
- }
- stock
- Fini_IsSet(ftag[])
- {
- format(fTag,maxtag,"%s=%s",ftag,Fini_GetStr(ftag));
- zNormal1 = strfind(fFile,ftag,true);
- if(zNormal1 != -1)
- return true;
- return false;
- }
- stock Fini_GetBool(ftag[])
- {
- new Seting = strval(Fini_GetStr(ftag));
- return Seting;
- }
Advertisement
Add Comment
Please, Sign In to add comment