Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- #include <zcmd>
- #include <sscanf2>
- #define DIALOG_HAUS 8
- #define MAX_HAUS 150
- new inHaus[MAX_PLAYERS] = -1;
- enum haus_info
- {
- Float:haus_x,
- Float:haus_y,
- Float:haus_z,
- haus_besitzer[32],
- haus_preis,
- haus_pickup,
- haus_innenraum,
- Text3D:haus_label,
- Hauskasse,
- haus_mietpreis
- }
- new HausInfo[MAX_HAUS][haus_info];
- enum innenraum_info
- {
- Float:innen_x,
- Float:innen_y,
- Float:innen_z,
- innen_interior
- }
- new HausInnenraum[][innenraum_info] =
- {
- {235.508994,1189.169897,1080.339966,3},
- {225.756989,1240.000000,1082.149902,2},
- {223.043991,1289.259888,1082.199951,1},
- {225.630997,1022.479980,1084.069946,7},
- {295.138977,1474.469971,1080.519897,15},
- {328.493988,1480.589966,1084.449951,15},
- {385.803986,1471.769897,1080.209961,15},
- {244.411987,305.032989,999.148437,1},
- {1527.229980,-11.574499,1002.097106,3},
- {2454.717041,-1700.871582,1013.515197,2},
- {2324.419921,-1145.568359,1050.710083,12},
- {1267.663208,-781.323242,1091.906250,5},
- {82.95,1322.44,1083.89,9},
- {-260.6,1456.62,1084.45,4},
- {-42.58,1405.61,1085.45,8},
- {-68.69,1351.97,1080.28,6},
- {2333.11,-1077.1,1049.04,6},
- {2365.3,-1134.92,1050.91,8},
- {2282.91,-1140.29,1050.91,11},
- {2196.79,-1204.35,1049.05,6},
- {2270.39,-1210.45,1047.57,10},
- {2308.79,-1212.88,1049.03,6},
- {2237.59,-1080.87,1049.07,2},
- {2317.82,-1026.75,1050.21,9}
- };
- new bool:Gemietet[MAX_PLAYERS];
- #define sprintf(%0) \
- (sprintf_bufidx = (sprintf_bufidx + 1) % sizeof sprintf_buf, format(sprintf_buf[sprintf_bufidx], sizeof sprintf_buf[], %0), sprintf_buf[sprintf_bufidx])
- public OnGameModeInit()
- {
- UsePlayerPedAnims();
- DisableInteriorEnterExits();
- for(new haus=0;haus<MAX_HAUS;haus++)
- {
- LoadHaus(haus);
- }
- public OnGameModeExit()
- {
- for(new haus=0;haus<MAX_HAUS;haus++)
- {
- KillHaus(haus);
- }
- }
- public OnPlayerSpawn(playerid)
- {
- */////////////////////////*
- *///Einfach rausgezogen///*
- */////////////////////////*
- else if(GetPVarInt(playerid,"Spawn") == 0)
- {
- SetPlayerPos(playerid,Zivispawn);
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid,0);
- }
- else if(GetPVarInt(playerid,"Spawn") == 2)
- {
- if(GetPVarInt(playerid,"Haus") != -1)
- {
- new haus=GetPVarInt(playerid,"Haus");
- if(GetPVarInt(playerid,"Haus") > 0)
- {
- new innenraum = HausInfo[haus][haus_innenraum];
- SetPlayerPos(playerid,HausInnenraum[innenraum][innen_x],HausInnenraum[innenraum][innen_y],HausInnenraum[innenraum][innen_z]);
- SetPlayerInterior(playerid,HausInnenraum[innenraum][innen_interior]);
- SetPlayerVirtualWorld(playerid,haus);
- inHaus[playerid] = haus;
- }
- else
- {
- SetPlayerPos(playerid,Zivispawn);
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid,0);
- }
- }
- }
- return 1;
- }
- public LevelZeit(playerid)
- {
- SetPVarInt(playerid,"Gesamtspielzeit",GetPVarInt(playerid,"Gesamtspielzeit")+1);;
- {
- {
- if(GetPVarInt(playerid,"Haus") > 0)
- {
- new Hausdatei[64];
- new Haus1 = GetPVarInt(playerid,"Haus");
- new pfad[50];
- format(pfad,sizeof(pfad),"/Haus/%d.txt",Haus1);
- HausInfo[Haus1][haus_mietpreis] = dini_Int(pfad,"Miete");
- new kasse=dini_Int(pfad,"Hauskasse");
- GivePlayerMoney(playerid,-HausInfo[Haus1][haus_mietpreis]);
- dini_IntSet(Hausdatei,"Hauskasse",kasse+HausInfo[Haus1][haus_mietpreis]);
- SendClientMessageToAll(hellblau,sprintf("Miete: %i",HausInfo[Haus1][haus_mietpreis]));
- }
- }
- }
- return 1;
- }
- */////////////////////////*
- *///Einfach rausgezogen///*
- */////////////////////////*
- CMD:exit(playerid,params[])
- {
- if(inHaus[playerid] >= 0)
- {
- new haus = inHaus[playerid];
- new innenraum = HausInfo[haus][haus_innenraum];
- if(IsPlayerInRangeOfPoint(playerid,5,HausInnenraum[innenraum][innen_x],HausInnenraum[innenraum][innen_y],HausInnenraum[innenraum][innen_z]))
- {
- SetPlayerPos(playerid,HausInfo[haus][haus_x],HausInfo[haus][haus_y],HausInfo[haus][haus_z]);
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid,0);
- inHaus[playerid] = -1;
- }
- }
- if(inBiz[playerid] >= 0)
- {
- new b = inBiz[playerid];
- new Innenraum = bInfo[b][Int];
- if(IsPlayerInRangeOfPoint(playerid,5,BizInnenraum[Innenraum][SpawnX],BizInnenraum[Innenraum][SpawnY],BizInnenraum[Innenraum][SpawnZ]))
- {
- SetPlayerPos(playerid,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]);
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid,0);
- inBiz[playerid] = -1;
- }
- }
- */////////////////////////*
- *///Einfach rausgezogen///*
- */////////////////////////*
- CMD:enter(playerid,params[])
- {
- for(new b=0;b<MAX_BIZ;b++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
- {
- new innenraum = bInfo[b][Int];
- SetPlayerPos(playerid,BizInnenraum[innenraum][SpawnX],BizInnenraum[innenraum][SpawnY],BizInnenraum[innenraum][SpawnZ]);
- SetPlayerInterior(playerid,BizInnenraum[innenraum][Int]);
- SetPlayerVirtualWorld(playerid,b);
- inBiz[playerid] = b;
- }
- }
- for(new haus=0;haus<MAX_HAUS;haus++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[haus][haus_x],HausInfo[haus][haus_y],HausInfo[haus][haus_z]))
- {
- if(strcmp(HausInfo[haus][haus_besitzer],"Keiner",false))
- {
- new innenraum = HausInfo[haus][haus_innenraum];
- SetPlayerPos(playerid,HausInnenraum[innenraum][innen_x],HausInnenraum[innenraum][innen_y],HausInnenraum[innenraum][innen_z]);
- SetPlayerInterior(playerid,HausInnenraum[innenraum][innen_interior]);
- SetPlayerVirtualWorld(playerid,haus);
- inHaus[playerid] = haus;
- }
- else SendClientMessage(playerid,ROT,"Das Haus hat keinen Besitzer.");
- }
- }
- */////////////////////////*
- *///Einfach rausgezogen///*
- */////////////////////////*
- CMD:sellplayerhaus(playerid,params[])
- {
- for(new i=0;i<MAX_HAUS;i++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
- {
- if(strcmp(HausInfo[i][haus_besitzer],SpielerName(playerid),false) == 0)
- {
- new pID;
- if(sscanf(params,"u",pID))return SendClientMessage(playerid,GRAU,"[Benutzung:] /sellplayerhaus [ID]");
- {
- if(IsPlayerConnected(pID))
- {
- if(GetPVarInt(pID,"Haus") >= 0)return SendClientMessage(playerid,ROT,"Der Spieler hat schon ein Haus.");
- new pfad[50];
- new string[128];
- format(pfad,sizeof(pfad),"/Haus/%d.txt",i);
- dini_Set(pfad,"besitzer",SpielerName(pID));
- SetPVarInt(playerid,"Haus",-1);
- SetPVarInt(pID,"Haus",i);
- format(string,sizeof(string),"Du hast dein Biz an %s abgegeben.",SpielerName(pID));
- SendClientMessage(playerid,GELB,string);
- format(string,sizeof(string),"%s hat sein Biz an dich abgegeben.",SpielerName(playerid));
- SendClientMessage(playerid,GELB,string);
- KillHaus(i);
- LoadHaus(i);
- }
- }
- }
- }
- }
- return 1;
- }
- CMD:hauscreate(playerid,params[])
- {
- new preis;
- new intid;
- if(isPlayerAnAdmin(playerid,7))
- {
- if(sscanf(params,"ii",preis,intid))return SendClientMessage(playerid,ROT,"/hcreate [Preis][Haus-Interior-ID]");
- if(intid < 0 || intid > sizeof(HausInnenraum))return SendClientMessage(playerid,ROT,"Haus-Interior-ID ist zu hoch oder zu niedrig.");
- if(intid == 1)return 1;
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- CreateHaus(x,y,z,preis,"Keiner",intid);
- }
- return 1;
- }
- CMD:delh(playerid,params[])
- {
- if(isPlayerAnAdmin(playerid,8))
- {
- for(new i=0;i<MAX_HAUS;i++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
- {
- new pfad[50];
- format(pfad,sizeof(pfad),"/Haus/%d.txt",i);
- dini_Remove(pfad);
- KillHaus(i);
- SendClientMessage(playerid,ROT,"Haus wurde zerstört.");
- }
- }
- }
- return 1;
- }
- CMD:setmiete(playerid,params[])
- {
- if(inHaus[playerid] >= 0)
- {
- new haus=inHaus[playerid];
- if(strcmp(HausInfo[haus][haus_besitzer],SpielerName(playerid),false) == 0)
- {
- new menge;
- if(sscanf(params,"i",menge))return SendClientMessage(playerid,GRAU,"[Benutzung:] /setmiete [betrag]");
- {
- new pfad[50];
- format(pfad,sizeof(pfad),"/Haus/%d.txt",haus);
- {
- new string[128];
- dini_IntSet(pfad,"Miete",menge);
- HausInfo[haus][haus_mietpreis] = dini_Int(pfad,"Miete");
- format(string,sizeof(string),"Du hast die Miete auf %i$ geändert!",menge);
- SendClientMessage(playerid,WEISS,string);
- KillHaus(haus);
- LoadHaus(haus);
- }
- }
- }
- }
- return 1;
- }
- CMD:mieten(playerid,params[])
- {
- for(new i=0;i<MAX_HAUS;i++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
- {
- new hausmiete = HausInfo[i][haus_mietpreis];
- SetPVarInt(playerid,"Haus",i);
- SetPVarInt(playerid,"Miete",hausmiete);
- SendClientMessage(playerid,GREEN,"Erfolgreich eingemietet!");
- KillHaus(i);
- LoadHaus(i);
- }
- }
- return 1;
- }
- CMD:ausziehen(playerid,params[])
- {
- SetPVarInt(playerid,"Haus",0);
- SetPVarInt(playerid,"Miete",0);
- SendClientMessage(playerid,GREEN,"Erfolgreich ausgemietet!");
- return 1;
- }
- CMD:showmiete(playerid,params[])
- {
- new string[50];
- new Miete1= GetPVarInt(playerid,"Miete");
- format(string,sizeof(string),"Miete beträgt: %i.",Miete1);
- SendClientMessage(playerid,GREEN,string);
- return 1;
- }
- CMD:buyhaus(playerid,params[])
- {
- if(GetPVarInt(playerid,"Haus") == 1)return SendClientMessage(playerid,ROT,"Du hast schon ein Haus.");
- for(new i=0;i<MAX_HAUS;i++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
- {
- if(strcmp(HausInfo[i][haus_besitzer],SpielerName(playerid),false) == 0)return SendClientMessage(playerid,ROT,"Das Haus gehört dir schon.");
- if(strcmp(HausInfo[i][haus_besitzer],"Keiner",false))return SendClientMessage(playerid,ROT,"Dieses Haus gehört jemand anderes. Du kannst es nicht mehr kaufen.");
- if(GetPlayerMoney(playerid) < HausInfo[i][haus_preis])return SendClientMessage(playerid,ROT,"Du hast nicht genug Geld.");
- GivePlayerMoney(playerid,-HausInfo[i][haus_preis]);
- new pfad[50];
- format(pfad,sizeof(pfad),"/Haus/%d.txt",i);
- dini_Set(pfad,"besitzer",SpielerName(playerid));
- SetPVarInt(playerid,"Haus",i);
- KillHaus(i);
- LoadHaus(i);
- }
- }
- return 1;
- }
- CMD:spawnchange(playerid,params[])
- {
- ShowPlayerDialog(playerid,DIALOG_SPAWNCHANGE,2,"Spawnchange","\nNoobspawn\nFraktionsspawn\nHaus","auswählen","abbrechen");
- return 1;
- }
- stock Register(playerid,key[])
- {
- new Spielerdatei[64];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
- dini_Create(Spielerdatei);
- dini_Set(Spielerdatei,"Darum",key);
- dini_Set(Spielerdatei,"Passwort",key);
- SetPlayerScore(playerid,1);
- SetPVarInt(playerid,"loggedin",1);
- SetPVarInt(playerid,"Adminlevel",0);
- SetPVarInt(playerid,"Firstlog",1);
- SetPVarInt(playerid,"Fraktion",0);
- SetPVarInt(playerid,"Skin",251);
- SetPVarInt(playerid,"Baned",0);
- SetPVarInt(playerid,"Rang",0);
- SetPVarInt(playerid,"Haus",0);
- return 1;
- }
- stock LoadAccount(playerid)
- {
- new Spielerdatei[64];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
- SetPlayerScore(playerid,dini_Int(Spielerdatei,"Level"));
- SetPVarInt(playerid,"Skin",dini_Int(Spielerdatei,"Skin"));
- SetPlayerWantedLevel(playerid,dini_Int(Spielerdatei,"WantedLevel"));
- GivePlayerMoney(playerid,dini_Int(Spielerdatei,"Geld"));
- SetPVarInt(playerid,"Adminlevel",dini_Int(Spielerdatei,"Adminlevel"));
- SetPVarInt(playerid,"Fraktion",dini_Int(Spielerdatei,"Fraktion"));
- SetPVarInt(playerid,"Baned",dini_Int(Spielerdatei,"Baned"));
- SetPVarInt(playerid,"Rang",dini_Int(Spielerdatei,"Rang"));
- SetPVarInt(playerid,"Haus",dini_Int(Spielerdatei,"Haus"));
- SetPVarInt(playerid,"Miete",dini_Int(Spielerdatei,"Miete"));
- SetPVarInt(playerid,"Spawn",dini_Int(Spielerdatei,"Spawn"));
- if(GetPVarInt(playerid,"Baned")==1)
- {
- SendClientMessage(playerid,ROT,"Du bist vom Server gebannt! Melde dich bei einen Teammitglied.");
- Kick(playerid);
- }
- SetPVarInt(playerid,"loggedin",1);
- return 1;
- }
- stock CreateHaus(Float:x,Float:y,Float:z,preis,besitzer[32],innenraum)
- {
- new pfad[50];
- for(new haus=1;haus<MAX_HAUS;haus++)
- {
- format(pfad,sizeof(pfad),"/Haus/%d.txt",haus);
- if(!fexist(pfad))
- {
- dini_Create(pfad);
- dini_FloatSet(pfad,"x",x);
- dini_FloatSet(pfad,"y",y);
- dini_FloatSet(pfad,"z",z);
- dini_IntSet(pfad,"Miete",1000);
- dini_IntSet(pfad,"preis",preis);
- dini_Set(pfad,"besitzer",besitzer);
- dini_IntSet(pfad,"innenraum",innenraum);
- return LoadHaus(haus);
- }
- }
- return 0;
- }
- stock LoadHaus(hausid)
- {
- new pfad[50];
- format(pfad,sizeof(pfad),"/Haus/%d.txt",hausid);
- if(dini_Exists(pfad))
- {
- HausInfo[hausid][haus_x] = dini_Float(pfad,"x");
- HausInfo[hausid][haus_y] = dini_Float(pfad,"y");
- HausInfo[hausid][haus_z] = dini_Float(pfad,"z");
- HausInfo[hausid][haus_mietpreis] = dini_Int(pfad,"Miete");
- HausInfo[hausid][haus_preis] = dini_Int(pfad,"preis");
- HausInfo[hausid][haus_innenraum] = dini_Int(pfad,"innenraum");
- format(HausInfo[hausid][haus_besitzer],32,"%s",dini_Get(pfad,"besitzer"));
- new s[128];
- if(strcmp(HausInfo[hausid][haus_besitzer],"Keiner",false) == 0)
- {
- HausInfo[hausid][haus_pickup] = CreatePickup(1273,23,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],0);
- format(s,sizeof(s),"*****Haus*****\nBesitzer: %s\nPreis: %d$",HausInfo[hausid][haus_besitzer],HausInfo[hausid][haus_preis]);
- HausInfo[hausid][haus_label] = Create3DTextLabel(s,BLAU,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],20,0,1);
- }
- else if(strcmp(HausInfo[hausid][haus_besitzer],"Keiner",false))
- {
- HausInfo[hausid][haus_pickup] = CreatePickup(1272,23,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],0);
- format(s,sizeof(s),"*****Haus*****\nBesitzer: %s \nMiete: %d$",HausInfo[hausid][haus_besitzer],HausInfo[hausid][haus_mietpreis]);
- HausInfo[hausid][haus_label] = Create3DTextLabel(s,BLAU,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],20,0,1);
- return printf("Haus %d erfolgreich geladen.",hausid);
- }
- }
- return 1;
- }
- stock KillHaus(hausid)
- {
- Delete3DTextLabel(HausInfo[hausid][haus_label]);
- DestroyPickup(HausInfo[hausid][haus_pickup]);
- return 1;
- }
Add Comment
Please, Sign In to add comment