germandavin

Untitled

Mar 2nd, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.38 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <zcmd>
  4. #include <sscanf2>
  5.  
  6. #define DIALOG_HAUS 8
  7.  
  8. #define MAX_HAUS 150
  9.  
  10. new inHaus[MAX_PLAYERS] = -1;
  11. enum haus_info
  12. {
  13. Float:haus_x,
  14. Float:haus_y,
  15. Float:haus_z,
  16. haus_besitzer[32],
  17. haus_preis,
  18. haus_pickup,
  19. haus_innenraum,
  20. Text3D:haus_label,
  21. Hauskasse,
  22. haus_mietpreis
  23. }
  24.  
  25. new HausInfo[MAX_HAUS][haus_info];
  26.  
  27. enum innenraum_info
  28. {
  29. Float:innen_x,
  30. Float:innen_y,
  31. Float:innen_z,
  32. innen_interior
  33. }
  34.  
  35. new HausInnenraum[][innenraum_info] =
  36. {
  37. {235.508994,1189.169897,1080.339966,3},
  38. {225.756989,1240.000000,1082.149902,2},
  39. {223.043991,1289.259888,1082.199951,1},
  40. {225.630997,1022.479980,1084.069946,7},
  41. {295.138977,1474.469971,1080.519897,15},
  42. {328.493988,1480.589966,1084.449951,15},
  43. {385.803986,1471.769897,1080.209961,15},
  44. {244.411987,305.032989,999.148437,1},
  45. {1527.229980,-11.574499,1002.097106,3},
  46. {2454.717041,-1700.871582,1013.515197,2},
  47. {2324.419921,-1145.568359,1050.710083,12},
  48. {1267.663208,-781.323242,1091.906250,5},
  49. {82.95,1322.44,1083.89,9},
  50. {-260.6,1456.62,1084.45,4},
  51. {-42.58,1405.61,1085.45,8},
  52. {-68.69,1351.97,1080.28,6},
  53. {2333.11,-1077.1,1049.04,6},
  54. {2365.3,-1134.92,1050.91,8},
  55. {2282.91,-1140.29,1050.91,11},
  56. {2196.79,-1204.35,1049.05,6},
  57. {2270.39,-1210.45,1047.57,10},
  58. {2308.79,-1212.88,1049.03,6},
  59. {2237.59,-1080.87,1049.07,2},
  60. {2317.82,-1026.75,1050.21,9}
  61. };
  62.  
  63. new bool:Gemietet[MAX_PLAYERS];
  64.  
  65. #define sprintf(%0) \
  66. (sprintf_bufidx = (sprintf_bufidx + 1) % sizeof sprintf_buf, format(sprintf_buf[sprintf_bufidx], sizeof sprintf_buf[], %0), sprintf_buf[sprintf_bufidx])
  67.  
  68. public OnGameModeInit()
  69. {
  70. UsePlayerPedAnims();
  71. DisableInteriorEnterExits();
  72. for(new haus=0;haus<MAX_HAUS;haus++)
  73. {
  74. LoadHaus(haus);
  75. }
  76.  
  77. public OnGameModeExit()
  78. {
  79. for(new haus=0;haus<MAX_HAUS;haus++)
  80. {
  81. KillHaus(haus);
  82. }
  83. }
  84. public OnPlayerSpawn(playerid)
  85. {
  86. */////////////////////////*
  87. *///Einfach rausgezogen///*
  88. */////////////////////////*
  89.  
  90. else if(GetPVarInt(playerid,"Spawn") == 0)
  91. {
  92. SetPlayerPos(playerid,Zivispawn);
  93. SetPlayerInterior(playerid,0);
  94. SetPlayerVirtualWorld(playerid,0);
  95. }
  96. else if(GetPVarInt(playerid,"Spawn") == 2)
  97. {
  98. if(GetPVarInt(playerid,"Haus") != -1)
  99. {
  100. new haus=GetPVarInt(playerid,"Haus");
  101. if(GetPVarInt(playerid,"Haus") > 0)
  102. {
  103. new innenraum = HausInfo[haus][haus_innenraum];
  104. SetPlayerPos(playerid,HausInnenraum[innenraum][innen_x],HausInnenraum[innenraum][innen_y],HausInnenraum[innenraum][innen_z]);
  105. SetPlayerInterior(playerid,HausInnenraum[innenraum][innen_interior]);
  106. SetPlayerVirtualWorld(playerid,haus);
  107. inHaus[playerid] = haus;
  108. }
  109. else
  110. {
  111. SetPlayerPos(playerid,Zivispawn);
  112. SetPlayerInterior(playerid,0);
  113. SetPlayerVirtualWorld(playerid,0);
  114. }
  115. }
  116. }
  117. return 1;
  118. }
  119.  
  120.  
  121.  
  122. public LevelZeit(playerid)
  123. {
  124. SetPVarInt(playerid,"Gesamtspielzeit",GetPVarInt(playerid,"Gesamtspielzeit")+1);;
  125. {
  126. {
  127.  
  128. if(GetPVarInt(playerid,"Haus") > 0)
  129. {
  130. new Hausdatei[64];
  131. new Haus1 = GetPVarInt(playerid,"Haus");
  132. new pfad[50];
  133. format(pfad,sizeof(pfad),"/Haus/%d.txt",Haus1);
  134. HausInfo[Haus1][haus_mietpreis] = dini_Int(pfad,"Miete");
  135. new kasse=dini_Int(pfad,"Hauskasse");
  136. GivePlayerMoney(playerid,-HausInfo[Haus1][haus_mietpreis]);
  137. dini_IntSet(Hausdatei,"Hauskasse",kasse+HausInfo[Haus1][haus_mietpreis]);
  138. SendClientMessageToAll(hellblau,sprintf("Miete: %i",HausInfo[Haus1][haus_mietpreis]));
  139.  
  140. }
  141.  
  142.  
  143. }
  144.  
  145.  
  146. }
  147. return 1;
  148. }
  149.  
  150.  
  151.  
  152.  
  153. */////////////////////////*
  154. *///Einfach rausgezogen///*
  155. */////////////////////////*
  156.  
  157.  
  158. CMD:exit(playerid,params[])
  159. {
  160. if(inHaus[playerid] >= 0)
  161. {
  162. new haus = inHaus[playerid];
  163. new innenraum = HausInfo[haus][haus_innenraum];
  164. if(IsPlayerInRangeOfPoint(playerid,5,HausInnenraum[innenraum][innen_x],HausInnenraum[innenraum][innen_y],HausInnenraum[innenraum][innen_z]))
  165. {
  166. SetPlayerPos(playerid,HausInfo[haus][haus_x],HausInfo[haus][haus_y],HausInfo[haus][haus_z]);
  167. SetPlayerInterior(playerid,0);
  168. SetPlayerVirtualWorld(playerid,0);
  169. inHaus[playerid] = -1;
  170. }
  171. }
  172. if(inBiz[playerid] >= 0)
  173. {
  174. new b = inBiz[playerid];
  175. new Innenraum = bInfo[b][Int];
  176. if(IsPlayerInRangeOfPoint(playerid,5,BizInnenraum[Innenraum][SpawnX],BizInnenraum[Innenraum][SpawnY],BizInnenraum[Innenraum][SpawnZ]))
  177. {
  178. SetPlayerPos(playerid,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]);
  179. SetPlayerInterior(playerid,0);
  180. SetPlayerVirtualWorld(playerid,0);
  181. inBiz[playerid] = -1;
  182. }
  183. }
  184.  
  185.  
  186.  
  187. */////////////////////////*
  188. *///Einfach rausgezogen///*
  189. */////////////////////////*
  190. CMD:enter(playerid,params[])
  191. {
  192.  
  193. for(new b=0;b<MAX_BIZ;b++)
  194. {
  195. if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
  196. {
  197. new innenraum = bInfo[b][Int];
  198. SetPlayerPos(playerid,BizInnenraum[innenraum][SpawnX],BizInnenraum[innenraum][SpawnY],BizInnenraum[innenraum][SpawnZ]);
  199. SetPlayerInterior(playerid,BizInnenraum[innenraum][Int]);
  200. SetPlayerVirtualWorld(playerid,b);
  201. inBiz[playerid] = b;
  202. }
  203. }
  204. for(new haus=0;haus<MAX_HAUS;haus++)
  205. {
  206. if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[haus][haus_x],HausInfo[haus][haus_y],HausInfo[haus][haus_z]))
  207. {
  208. if(strcmp(HausInfo[haus][haus_besitzer],"Keiner",false))
  209. {
  210. new innenraum = HausInfo[haus][haus_innenraum];
  211. SetPlayerPos(playerid,HausInnenraum[innenraum][innen_x],HausInnenraum[innenraum][innen_y],HausInnenraum[innenraum][innen_z]);
  212. SetPlayerInterior(playerid,HausInnenraum[innenraum][innen_interior]);
  213. SetPlayerVirtualWorld(playerid,haus);
  214. inHaus[playerid] = haus;
  215. }
  216. else SendClientMessage(playerid,ROT,"Das Haus hat keinen Besitzer.");
  217. }
  218. }
  219. */////////////////////////*
  220. *///Einfach rausgezogen///*
  221. */////////////////////////*
  222.  
  223.  
  224.  
  225.  
  226.  
  227. CMD:sellplayerhaus(playerid,params[])
  228. {
  229. for(new i=0;i<MAX_HAUS;i++)
  230. {
  231. if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
  232. {
  233. if(strcmp(HausInfo[i][haus_besitzer],SpielerName(playerid),false) == 0)
  234. {
  235. new pID;
  236. if(sscanf(params,"u",pID))return SendClientMessage(playerid,GRAU,"[Benutzung:] /sellplayerhaus [ID]");
  237. {
  238. if(IsPlayerConnected(pID))
  239. {
  240. if(GetPVarInt(pID,"Haus") >= 0)return SendClientMessage(playerid,ROT,"Der Spieler hat schon ein Haus.");
  241. new pfad[50];
  242. new string[128];
  243. format(pfad,sizeof(pfad),"/Haus/%d.txt",i);
  244. dini_Set(pfad,"besitzer",SpielerName(pID));
  245. SetPVarInt(playerid,"Haus",-1);
  246. SetPVarInt(pID,"Haus",i);
  247. format(string,sizeof(string),"Du hast dein Biz an %s abgegeben.",SpielerName(pID));
  248. SendClientMessage(playerid,GELB,string);
  249. format(string,sizeof(string),"%s hat sein Biz an dich abgegeben.",SpielerName(playerid));
  250. SendClientMessage(playerid,GELB,string);
  251. KillHaus(i);
  252. LoadHaus(i);
  253. }
  254. }
  255. }
  256. }
  257. }
  258. return 1;
  259. }
  260.  
  261. CMD:hauscreate(playerid,params[])
  262. {
  263. new preis;
  264. new intid;
  265. if(isPlayerAnAdmin(playerid,7))
  266. {
  267. if(sscanf(params,"ii",preis,intid))return SendClientMessage(playerid,ROT,"/hcreate [Preis][Haus-Interior-ID]");
  268. if(intid < 0 || intid > sizeof(HausInnenraum))return SendClientMessage(playerid,ROT,"Haus-Interior-ID ist zu hoch oder zu niedrig.");
  269. if(intid == 1)return 1;
  270. new Float:x,Float:y,Float:z;
  271. GetPlayerPos(playerid,x,y,z);
  272. CreateHaus(x,y,z,preis,"Keiner",intid);
  273. }
  274. return 1;
  275. }
  276. CMD:delh(playerid,params[])
  277. {
  278. if(isPlayerAnAdmin(playerid,8))
  279. {
  280. for(new i=0;i<MAX_HAUS;i++)
  281. {
  282. if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
  283. {
  284. new pfad[50];
  285. format(pfad,sizeof(pfad),"/Haus/%d.txt",i);
  286. dini_Remove(pfad);
  287. KillHaus(i);
  288. SendClientMessage(playerid,ROT,"Haus wurde zerstört.");
  289. }
  290. }
  291. }
  292. return 1;
  293. }
  294. CMD:setmiete(playerid,params[])
  295. {
  296. if(inHaus[playerid] >= 0)
  297. {
  298. new haus=inHaus[playerid];
  299. if(strcmp(HausInfo[haus][haus_besitzer],SpielerName(playerid),false) == 0)
  300. {
  301. new menge;
  302. if(sscanf(params,"i",menge))return SendClientMessage(playerid,GRAU,"[Benutzung:] /setmiete [betrag]");
  303. {
  304. new pfad[50];
  305. format(pfad,sizeof(pfad),"/Haus/%d.txt",haus);
  306. {
  307. new string[128];
  308. dini_IntSet(pfad,"Miete",menge);
  309. HausInfo[haus][haus_mietpreis] = dini_Int(pfad,"Miete");
  310. format(string,sizeof(string),"Du hast die Miete auf %i$ geändert!",menge);
  311. SendClientMessage(playerid,WEISS,string);
  312. KillHaus(haus);
  313. LoadHaus(haus);
  314.  
  315. }
  316. }
  317. }
  318. }
  319. return 1;
  320. }
  321.  
  322. CMD:mieten(playerid,params[])
  323. {
  324. for(new i=0;i<MAX_HAUS;i++)
  325. {
  326. if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
  327. {
  328. new hausmiete = HausInfo[i][haus_mietpreis];
  329. SetPVarInt(playerid,"Haus",i);
  330. SetPVarInt(playerid,"Miete",hausmiete);
  331. SendClientMessage(playerid,GREEN,"Erfolgreich eingemietet!");
  332. KillHaus(i);
  333. LoadHaus(i);
  334. }
  335. }
  336. return 1;
  337. }
  338. CMD:ausziehen(playerid,params[])
  339. {
  340.  
  341. SetPVarInt(playerid,"Haus",0);
  342. SetPVarInt(playerid,"Miete",0);
  343. SendClientMessage(playerid,GREEN,"Erfolgreich ausgemietet!");
  344. return 1;
  345. }
  346. CMD:showmiete(playerid,params[])
  347. {
  348. new string[50];
  349. new Miete1= GetPVarInt(playerid,"Miete");
  350. format(string,sizeof(string),"Miete beträgt: %i.",Miete1);
  351. SendClientMessage(playerid,GREEN,string);
  352. return 1;
  353. }
  354. CMD:buyhaus(playerid,params[])
  355. {
  356. if(GetPVarInt(playerid,"Haus") == 1)return SendClientMessage(playerid,ROT,"Du hast schon ein Haus.");
  357. for(new i=0;i<MAX_HAUS;i++)
  358. {
  359. if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[i][haus_x],HausInfo[i][haus_y],HausInfo[i][haus_z]))
  360. {
  361. if(strcmp(HausInfo[i][haus_besitzer],SpielerName(playerid),false) == 0)return SendClientMessage(playerid,ROT,"Das Haus gehört dir schon.");
  362. if(strcmp(HausInfo[i][haus_besitzer],"Keiner",false))return SendClientMessage(playerid,ROT,"Dieses Haus gehört jemand anderes. Du kannst es nicht mehr kaufen.");
  363. if(GetPlayerMoney(playerid) < HausInfo[i][haus_preis])return SendClientMessage(playerid,ROT,"Du hast nicht genug Geld.");
  364. GivePlayerMoney(playerid,-HausInfo[i][haus_preis]);
  365. new pfad[50];
  366. format(pfad,sizeof(pfad),"/Haus/%d.txt",i);
  367. dini_Set(pfad,"besitzer",SpielerName(playerid));
  368. SetPVarInt(playerid,"Haus",i);
  369. KillHaus(i);
  370. LoadHaus(i);
  371. }
  372. }
  373. return 1;
  374. }
  375.  
  376. CMD:spawnchange(playerid,params[])
  377. {
  378. ShowPlayerDialog(playerid,DIALOG_SPAWNCHANGE,2,"Spawnchange","\nNoobspawn\nFraktionsspawn\nHaus","auswählen","abbrechen");
  379. return 1;
  380. }
  381.  
  382. stock Register(playerid,key[])
  383. {
  384. new Spielerdatei[64];
  385. new name[MAX_PLAYER_NAME];
  386. GetPlayerName(playerid,name,sizeof(name));
  387. format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
  388. dini_Create(Spielerdatei);
  389. dini_Set(Spielerdatei,"Darum",key);
  390. dini_Set(Spielerdatei,"Passwort",key);
  391. SetPlayerScore(playerid,1);
  392. SetPVarInt(playerid,"loggedin",1);
  393. SetPVarInt(playerid,"Adminlevel",0);
  394. SetPVarInt(playerid,"Firstlog",1);
  395. SetPVarInt(playerid,"Fraktion",0);
  396. SetPVarInt(playerid,"Skin",251);
  397. SetPVarInt(playerid,"Baned",0);
  398. SetPVarInt(playerid,"Rang",0);
  399. SetPVarInt(playerid,"Haus",0);
  400. return 1;
  401. }
  402.  
  403.  
  404.  
  405. stock LoadAccount(playerid)
  406. {
  407. new Spielerdatei[64];
  408. new name[MAX_PLAYER_NAME];
  409. GetPlayerName(playerid,name,sizeof(name));
  410. format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
  411. SetPlayerScore(playerid,dini_Int(Spielerdatei,"Level"));
  412. SetPVarInt(playerid,"Skin",dini_Int(Spielerdatei,"Skin"));
  413. SetPlayerWantedLevel(playerid,dini_Int(Spielerdatei,"WantedLevel"));
  414. GivePlayerMoney(playerid,dini_Int(Spielerdatei,"Geld"));
  415. SetPVarInt(playerid,"Adminlevel",dini_Int(Spielerdatei,"Adminlevel"));
  416. SetPVarInt(playerid,"Fraktion",dini_Int(Spielerdatei,"Fraktion"));
  417. SetPVarInt(playerid,"Baned",dini_Int(Spielerdatei,"Baned"));
  418. SetPVarInt(playerid,"Rang",dini_Int(Spielerdatei,"Rang"));
  419. SetPVarInt(playerid,"Haus",dini_Int(Spielerdatei,"Haus"));
  420. SetPVarInt(playerid,"Miete",dini_Int(Spielerdatei,"Miete"));
  421. SetPVarInt(playerid,"Spawn",dini_Int(Spielerdatei,"Spawn"));
  422.  
  423. if(GetPVarInt(playerid,"Baned")==1)
  424. {
  425. SendClientMessage(playerid,ROT,"Du bist vom Server gebannt! Melde dich bei einen Teammitglied.");
  426. Kick(playerid);
  427. }
  428. SetPVarInt(playerid,"loggedin",1);
  429. return 1;
  430. }
  431.  
  432. stock CreateHaus(Float:x,Float:y,Float:z,preis,besitzer[32],innenraum)
  433. {
  434. new pfad[50];
  435. for(new haus=1;haus<MAX_HAUS;haus++)
  436. {
  437. format(pfad,sizeof(pfad),"/Haus/%d.txt",haus);
  438. if(!fexist(pfad))
  439. {
  440. dini_Create(pfad);
  441. dini_FloatSet(pfad,"x",x);
  442. dini_FloatSet(pfad,"y",y);
  443. dini_FloatSet(pfad,"z",z);
  444. dini_IntSet(pfad,"Miete",1000);
  445. dini_IntSet(pfad,"preis",preis);
  446. dini_Set(pfad,"besitzer",besitzer);
  447. dini_IntSet(pfad,"innenraum",innenraum);
  448. return LoadHaus(haus);
  449. }
  450. }
  451. return 0;
  452. }
  453.  
  454. stock LoadHaus(hausid)
  455. {
  456. new pfad[50];
  457. format(pfad,sizeof(pfad),"/Haus/%d.txt",hausid);
  458. if(dini_Exists(pfad))
  459. {
  460. HausInfo[hausid][haus_x] = dini_Float(pfad,"x");
  461. HausInfo[hausid][haus_y] = dini_Float(pfad,"y");
  462. HausInfo[hausid][haus_z] = dini_Float(pfad,"z");
  463. HausInfo[hausid][haus_mietpreis] = dini_Int(pfad,"Miete");
  464. HausInfo[hausid][haus_preis] = dini_Int(pfad,"preis");
  465. HausInfo[hausid][haus_innenraum] = dini_Int(pfad,"innenraum");
  466. format(HausInfo[hausid][haus_besitzer],32,"%s",dini_Get(pfad,"besitzer"));
  467. new s[128];
  468. if(strcmp(HausInfo[hausid][haus_besitzer],"Keiner",false) == 0)
  469. {
  470. HausInfo[hausid][haus_pickup] = CreatePickup(1273,23,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],0);
  471. format(s,sizeof(s),"*****Haus*****\nBesitzer: %s\nPreis: %d$",HausInfo[hausid][haus_besitzer],HausInfo[hausid][haus_preis]);
  472. HausInfo[hausid][haus_label] = Create3DTextLabel(s,BLAU,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],20,0,1);
  473. }
  474. else if(strcmp(HausInfo[hausid][haus_besitzer],"Keiner",false))
  475. {
  476. HausInfo[hausid][haus_pickup] = CreatePickup(1272,23,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],0);
  477. format(s,sizeof(s),"*****Haus*****\nBesitzer: %s \nMiete: %d$",HausInfo[hausid][haus_besitzer],HausInfo[hausid][haus_mietpreis]);
  478. HausInfo[hausid][haus_label] = Create3DTextLabel(s,BLAU,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],20,0,1);
  479. return printf("Haus %d erfolgreich geladen.",hausid);
  480. }
  481. }
  482. return 1;
  483. }
  484.  
  485. stock KillHaus(hausid)
  486. {
  487. Delete3DTextLabel(HausInfo[hausid][haus_label]);
  488. DestroyPickup(HausInfo[hausid][haus_pickup]);
  489. return 1;
  490. }
Add Comment
Please, Sign In to add comment