kSpade

samp planetside v0.2.2

Oct 19th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 22.13 KB | None | 0 0
  1. //------------------includes----------------------------------
  2. #include <a_samp>
  3. #include <YSI\y_ini>
  4. //------------------defines-----------------------------------
  5. #define COLOR_MAP_BALLAS        0x7647A277
  6. #define COLOR_MAP_GROVE         0x32CD3277
  7. #define COLOR_MAP_AZTECAS       0x00FFFF77
  8. #define COLOR_MAP_MAFIA         0x32323277
  9. #define COLOR_MAP_NA            0xFFFFFF77
  10. #define COLOR_MAP_TRANS         0xFFFFFF00
  11. #define COLOR_PLAYER_BALLAS     0x551A8B77
  12. #define COLOR_PLAYER_GROVE      0x00990077
  13. #define COLOR_PLAYER_AZTECAS    0x008B8B77
  14. #define COLOR_PLAYER_MAFIA      0x00000077
  15.  
  16. #define TOTAL_CPOINTS      12//Adjust accordingly
  17. #define TOTAL_STURFS       4
  18.  
  19. #define DIALOG_FACTION     1
  20. #define DIALOG_CLASS       2
  21.  
  22. #define FACTION_BALLAS     0
  23. #define FACTION_GROVE      1
  24. #define FACTION_AZTECAS    2
  25. #define FACTION_MAFIA      3
  26. #define FACTION_LESS       4
  27.  
  28. #define CLASS_LIGHT        0
  29. #define CLASS_HEAVY        1
  30. #define CLASS_SNIPER       2
  31.  
  32. #define MIN_X              0
  33. #define MAX_X              1
  34. #define MIN_Y              2
  35. #define MAX_Y              3
  36.  
  37. #define pX                 0
  38. #define pY                 1
  39. #define pZ                 2
  40.  
  41. #define waterX             137.4
  42. #define waterY             380.6
  43. #define waterZ             -7.7
  44.  
  45. #define FACTION            0
  46. #define CLASS              1
  47. #define INGAME             2
  48. #define HASPLAYED          3
  49. #define CUSTOMIZED         4
  50. #define WEAPONS            5
  51. #define AMMO               6
  52. //-------------------variables----------------------------------
  53. new
  54.     pData[MAX_PLAYERS][5],
  55.     pWeapons[MAX_PLAYERS][13][2],
  56.     spawnTurfs[TOTAL_STURFS],
  57.     capturePoint[TOTAL_CPOINTS],
  58.     takingPoint[TOTAL_CPOINTS],
  59.     shieldRegen[MAX_PLAYERS],
  60.     damageTaken[MAX_PLAYERS],
  61.     timer[TOTAL_CPOINTS],
  62.     delayTimer[MAX_PLAYERS],
  63.     lastPointOwner[TOTAL_CPOINTS]=
  64.     {FACTION_LESS,FACTION_LESS,FACTION_LESS,FACTION_LESS,FACTION_LESS,  // this is a rather annoying bug
  65.      FACTION_LESS,FACTION_LESS,FACTION_LESS,FACTION_LESS,FACTION_LESS, // you need to add FACTION_LESS for
  66.      FACTION_LESS,FACTION_LESS};                                      // every capture point, or it'll show as ballers
  67.  new
  68.     Float:stXY[TOTAL_STURFS][4],
  69.     Float:cpXY[TOTAL_CPOINTS][4],
  70.     Float:pPos[TOTAL_CPOINTS][3];
  71. //------------------forwards----------------------------------
  72. forward
  73.     EnableShieldRegen(playerid);
  74.     SetZone(playerid,point);
  75.     SetPlayerPosDelayed(playerid);
  76.     Loadstxy(tag[], name[], value[]);
  77.     Loadcpxy(tag[], name[], value[]);
  78.     LoadpPos(tag[], name[], value[]);
  79.     LoadPlayerData(playerid,tag[],name[],value[]);
  80.     SavePlayerData(playerid);
  81. //---------------------filter script----------------------------------
  82. public OnFilterScriptInit()
  83. {
  84.     INI_ParseFile("planetside/stxy.ini", "Loadstxy", .bPassTag = true);
  85.     INI_ParseFile("planetside/cpxy.ini", "Loadcpxy", .bPassTag = true);
  86.     INI_ParseFile("planetside/ppos.ini", "LoadpPos", .bPassTag = true);
  87.  
  88.     for(new i;i<TOTAL_STURFS;i++) spawnTurfs[i] = GangZoneCreate(stXY[i][MIN_X],stXY[i][MIN_Y],stXY[i][MAX_X],stXY[i][MAX_Y]);
  89.     for(new i;i<TOTAL_CPOINTS;i++) capturePoint[i]= GangZoneCreate(cpXY[i][MIN_X],cpXY[i][MIN_Y],cpXY[i][MAX_X],cpXY[i][MAX_Y]);
  90.     for(new i;i<TOTAL_CPOINTS;i++) CreatePickup(1318,1,pPos[i][pX],pPos[i][pY],pPos[i][pZ],-1);
  91.  
  92.     print("\n--------------------------------------");
  93.     print(" fail planetside by kSpade");
  94.     print("--------------------------------------\n");
  95.  
  96.     return 1;
  97. }
  98. public OnFilterScriptExit()
  99. {
  100.     for(new i;i<TOTAL_CPOINTS;i++)GangZoneShowForAll(capturePoint[i],COLOR_MAP_TRANS);
  101.     for(new i;i<TOTAL_STURFS;i++)GangZoneShowForAll(spawnTurfs[i],COLOR_MAP_TRANS);
  102.     for(new i;i<MAX_PLAYERS;i++)
  103.     {
  104.         if(pData[i][INGAME]==1)SetPlayerHealth(i,0.0);
  105.         SavePlayerData(i);
  106.     }
  107.     return 1;
  108. }
  109. //--------------------On Player Stuff---------------------------
  110. public OnPlayerCommandText(playerid, cmdtext[])
  111. {
  112.     if (strcmp("/joingame",cmdtext,true,10)==0)
  113.     {
  114.         ShowPlayerDialog(playerid, DIALOG_FACTION, DIALOG_STYLE_LIST, "Choose Faction",
  115.         "Ballas\nGrove Street\nVarios Los Aztecas\nMafia", "Select", "Close");
  116.         return 1;
  117.     }
  118.     if (strcmp("/testdatasave",cmdtext,true,10)==0)
  119.     {
  120.         SavePlayerData(playerid);
  121.         return 1;
  122.     }
  123.     return 0;
  124. }
  125. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  126. {
  127.     if(pData[playerid][INGAME]==1)
  128.     {
  129.         if(IsPlayerInTurf(playerid)||IsPlayerInTurf(issuerid))
  130.         {
  131.             SendClientMessage(playerid,-1,"Turf Protection v1.1");
  132.             if(IsPlayerInWater(playerid)||weaponid==37)
  133.             {
  134.                 SetPlayerPos(playerid,waterX,waterY,waterZ);
  135.                 delayTimer[playerid]=SetTimerEx("SetPlayerPosDelayed",1000,false,"%i",playerid);
  136.             }
  137.             SetPlayerHealth(playerid,1000.0);
  138.             SetPlayerArmour(playerid,100.0);
  139.             return 1;
  140.         }
  141.         KillTimer(damageTaken[playerid]);
  142.         shieldRegen[playerid]=0;
  143.         damageTaken[playerid]=SetTimerEx("EnableShieldRegen",5000,false,"i",playerid);
  144.     }
  145.     return 1;
  146. }
  147. public OnPlayerUpdate(playerid)
  148. {
  149.     if(!IsPlayerConnected(playerid)) return 0;
  150.     if(IsPlayerNPC(playerid)) return 1;
  151.  
  152.     if(shieldRegen[playerid]==1)
  153.     {
  154.         new Float:armor;
  155.         GetPlayerArmour(playerid,armor);
  156.         if(armor<=99.0)SetPlayerArmour(playerid,armor+1.0);
  157.     }
  158.     if(pData[playerid][INGAME]==1)
  159.     {
  160.         for(new i;i<TOTAL_CPOINTS;i++)
  161.         {
  162.             if(IsPlayerInRangeOfPoint(playerid,5,pPos[i][pX],pPos[i][pY],pPos[i][pZ])) StartCapture(playerid,i);
  163.             else
  164.             {
  165.                   if(takingPoint[i]==1)
  166.                 {
  167.                     UpdatePointStatus(playerid,i,0);
  168.                     KillTimer(timer[i]);
  169.                 }
  170.             }
  171.         }
  172.     }
  173.     return 1;
  174. }
  175. public OnPlayerSpawn(playerid)
  176. {
  177.     GangZoneShowForPlayer(playerid, spawnTurfs[0], COLOR_MAP_GROVE);
  178.     GangZoneShowForPlayer(playerid, spawnTurfs[1], COLOR_MAP_BALLAS);
  179.     GangZoneShowForPlayer(playerid, spawnTurfs[2], COLOR_MAP_AZTECAS);
  180.     GangZoneShowForPlayer(playerid, spawnTurfs[3], COLOR_MAP_MAFIA);
  181.  
  182.     for(new i;i<TOTAL_CPOINTS;i++)
  183.     {
  184.         SetPlayerMapIcon(playerid,i,pPos[i][pX],pPos[i][pY],pPos[i][pZ],0,-1,1);
  185.         switch(lastPointOwner[i])
  186.         {
  187.             case FACTION_BALLAS: GangZoneShowForPlayer(playerid, capturePoint[i], COLOR_MAP_BALLAS);
  188.             case FACTION_GROVE: GangZoneShowForPlayer(playerid, capturePoint[i], COLOR_MAP_GROVE);
  189.             case FACTION_AZTECAS: GangZoneShowForPlayer(playerid, capturePoint[i], COLOR_MAP_AZTECAS);
  190.             case FACTION_MAFIA: GangZoneShowForPlayer(playerid, capturePoint[i], COLOR_MAP_MAFIA);
  191.             case FACTION_LESS: GangZoneShowForPlayer(playerid, capturePoint[i], COLOR_MAP_NA);
  192.         }
  193.     }
  194.     ResetPlayerWeapons(playerid);
  195.     if(pData[playerid][HASPLAYED]==1) pData[playerid][INGAME]=1;
  196.     if(pData[playerid][INGAME]==1)
  197.     {
  198.         SetFactionSkin(playerid);
  199.         if(pData[playerid][CUSTOMIZED]!=1) GiveClassWeapons(playerid);
  200.         else for(new i;i<=12;i++) GivePlayerWeapon(playerid,pWeapons[playerid][i][0],pWeapons[playerid][i][1]);
  201.         delayTimer[playerid]=SetTimerEx("SetPlayerPosDelayed",1000,false,"i",playerid);
  202.     }
  203.     else
  204.     {
  205.         ShowPlayerDialog(playerid, DIALOG_FACTION, DIALOG_STYLE_LIST, "Choose Faction",
  206.         "Ballas\nGrove Street\nVarios Los Aztecas\nMafia", "Select", "Close");
  207.     }
  208. }
  209. public OnPlayerConnect(playerid)
  210. {
  211.     new
  212.         playerName[MAX_PLAYER_NAME],
  213.         userFile[64];
  214.     GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  215.     format(userFile,sizeof(userFile),"%s",playerName);
  216.     INI_ParseFile(userFile,"LoadPlayerData", .bExtra = true, .extra = playerid, .bPassTag = true);
  217. }
  218. public OnPlayerDisconnect(playerid)
  219. {
  220.     pData[playerid][INGAME]=0;
  221.     pData[playerid][HASPLAYED]=1;
  222.     SavePlayerData(playerid);
  223.     return 1;
  224. }
  225. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  226. {
  227.     if(dialogid == DIALOG_FACTION)
  228.     {
  229.         if(response)
  230.         {
  231.             switch(listitem)
  232.             {
  233.                 case FACTION_BALLAS: pData[playerid][FACTION]=FACTION_BALLAS;
  234.                 case FACTION_GROVE: pData[playerid][FACTION]=FACTION_GROVE;
  235.                 case FACTION_AZTECAS: pData[playerid][FACTION]=FACTION_AZTECAS;
  236.                 case FACTION_MAFIA: pData[playerid][FACTION]=FACTION_MAFIA;
  237.             }
  238.             ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Choose Class",
  239.             "Light Assault\nHeavy Assault\nSniper", "Select", "Close");
  240.             return 1;
  241.         }
  242.     }
  243.     else if(dialogid == DIALOG_CLASS)
  244.     {
  245.         if(response)
  246.         {
  247.             ResetPlayerWeapons(playerid);
  248.             pData[playerid][INGAME]=1;
  249.             switch(listitem)
  250.             {
  251.                 case CLASS_LIGHT: pData[playerid][CLASS]=CLASS_LIGHT;
  252.                 case CLASS_HEAVY: pData[playerid][CLASS]=CLASS_HEAVY;
  253.                 case CLASS_SNIPER: pData[playerid][CLASS]=CLASS_SNIPER;
  254.             }
  255.             SetPlayerHealth(playerid,0.0);
  256.             SetFactionSkin(playerid);
  257.             GiveClassWeapons(playerid);
  258.         }
  259.         return 1;
  260.     }
  261.     return 0;
  262. }
  263. public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
  264. {
  265.     for(new i;i<TOTAL_CPOINTS;i++)
  266.     {
  267.         if(fX >= cpXY[i][MIN_X] && fX <= cpXY[i][MAX_X] && fY >= cpXY[i][MIN_Y] && fY <= cpXY[i][MAX_Y])
  268.         {
  269.             if(pData[playerid][FACTION]==lastPointOwner[i])
  270.             {
  271.                 SetPlayerPos(playerid,fX,fY,fZ+1000);
  272.                 GivePlayerWeapon(playerid,46,1);
  273.             }
  274.         }
  275.     }
  276. }
  277. //-------------------------functions-------------------------------------
  278. public SetPlayerPosDelayed(playerid)
  279. {
  280.     switch(pData[playerid][FACTION])
  281.      {
  282.         case FACTION_BALLAS:
  283.         {
  284.             SetPlayerPos(playerid,-2477.12,2337.56,4.98);
  285.             SetPlayerFacingAngle(playerid,218.85);
  286.         }
  287.         case FACTION_GROVE:
  288.         {
  289.             SetPlayerPos(playerid,2672.40,-2431.00,13.63);
  290.             SetPlayerFacingAngle(playerid,281.00);
  291.         }
  292.         case FACTION_AZTECAS:
  293.         {
  294.             SetPlayerPos(playerid,2627.54,2758.31,23.82);
  295.             SetPlayerFacingAngle(playerid,122.03);
  296.         }
  297.          case FACTION_MAFIA:
  298.         {
  299.             SetPlayerPos(playerid,-2159.77,-2415.11,30.62);
  300.             SetPlayerFacingAngle(playerid,260.22);
  301.         }
  302.  
  303.     }
  304. }
  305. stock SetFactionSkin(playerid)
  306. {
  307.     switch(pData[playerid][FACTION])
  308.     {
  309.         case FACTION_BALLAS:
  310.         {
  311.             if(pData[playerid][CLASS]==CLASS_LIGHT)SetPlayerSkinFix(playerid, 102);
  312.             if(pData[playerid][CLASS]==CLASS_HEAVY)SetPlayerSkinFix(playerid, 103);
  313.             if(pData[playerid][CLASS]==CLASS_SNIPER)SetPlayerSkinFix(playerid, 104);
  314.             SetPlayerColor(playerid,COLOR_PLAYER_BALLAS);
  315.         }
  316.         case FACTION_GROVE:
  317.         {
  318.             if(pData[playerid][CLASS]==CLASS_LIGHT)SetPlayerSkinFix(playerid, 107);
  319.             if(pData[playerid][CLASS]==CLASS_HEAVY)SetPlayerSkinFix(playerid, 105);
  320.             if(pData[playerid][CLASS]==CLASS_SNIPER)SetPlayerSkinFix(playerid, 106);
  321.             SetPlayerColor(playerid,COLOR_PLAYER_GROVE);
  322.         }
  323.         case FACTION_AZTECAS:
  324.         {
  325.             if(pData[playerid][CLASS]==CLASS_LIGHT)SetPlayerSkinFix(playerid, 114);
  326.             if(pData[playerid][CLASS]==CLASS_HEAVY)SetPlayerSkinFix(playerid, 115);
  327.             if(pData[playerid][CLASS]==CLASS_SNIPER)SetPlayerSkinFix(playerid, 116);
  328.             SetPlayerColor(playerid,COLOR_PLAYER_AZTECAS);
  329.         }
  330.         case FACTION_MAFIA:
  331.         {
  332.             if(pData[playerid][CLASS]==CLASS_LIGHT)SetPlayerSkinFix(playerid, 124);
  333.             if(pData[playerid][CLASS]==CLASS_HEAVY)SetPlayerSkinFix(playerid, 125);
  334.             if(pData[playerid][CLASS]==CLASS_SNIPER)SetPlayerSkinFix(playerid, 126);
  335.             SetPlayerColor(playerid,COLOR_PLAYER_MAFIA);
  336.         }
  337.     }
  338.     return 1;
  339. }
  340. stock GiveClassWeapons(playerid)
  341. {
  342.     switch(pData[playerid][CLASS])
  343.     {
  344.         case CLASS_LIGHT:
  345.         {
  346.             GivePlayerWeapon(playerid,16,2);
  347.             GivePlayerWeapon(playerid,22,500);
  348.             GivePlayerWeapon(playerid,29,500);
  349.         }
  350.         case CLASS_HEAVY:
  351.         {
  352.             GivePlayerWeapon(playerid,35,4);
  353.             GivePlayerWeapon(playerid,24,500);
  354.             GivePlayerWeapon(playerid,30,500);
  355.         }
  356.         case CLASS_SNIPER:
  357.         {
  358.             GivePlayerWeapon(playerid,16,2);
  359.             GivePlayerWeapon(playerid,23,500);
  360.             GivePlayerWeapon(playerid,34,500);
  361.         }
  362.     }
  363.     return 1;
  364. }
  365. public EnableShieldRegen(playerid)
  366. {
  367.     shieldRegen[playerid]=1;
  368.     return 1;
  369. }
  370. stock UpdatePointStatus(playerid,point,status)
  371. {
  372.     if(status==1)
  373.     {
  374.         new msgToAlly[64],msgToOwner[64],temp[8];
  375.         switch(pData[playerid][FACTION])
  376.         {
  377.             case 0:temp="Ballas";
  378.             case 1:temp="Grove";
  379.             case 2:temp="Aztecas";
  380.             case 3:temp="Mafia";
  381.         }
  382.         format(msgToAlly,sizeof(msgToAlly),"Taking over point %i",point);
  383.         format(msgToOwner,sizeof(msgToOwner),"Point %i is being taken over by the %s!",point,temp);
  384.         for(new i;i<MAX_PLAYERS;i++)
  385.         {
  386.             if(pData[i][FACTION]==pData[playerid][FACTION]) SendClientMessage(i,-1,msgToAlly);
  387.             if(lastPointOwner[point]==pData[i][FACTION])SendClientMessage(i,-1,msgToOwner);
  388.         }
  389.         takingPoint[point]=1;
  390.         switch(pData[playerid][FACTION])
  391.         {
  392.             case FACTION_BALLAS: GangZoneFlashForAll(capturePoint[point],COLOR_MAP_BALLAS);
  393.             case FACTION_GROVE: GangZoneFlashForAll(capturePoint[point],COLOR_MAP_GROVE);
  394.             case FACTION_AZTECAS: GangZoneFlashForAll(capturePoint[point],COLOR_MAP_AZTECAS);
  395.             case FACTION_MAFIA: GangZoneFlashForAll(capturePoint[point],COLOR_MAP_MAFIA);
  396.         }
  397.     }
  398.     else
  399.     {
  400.         for(new i;i<MAX_PLAYERS;i++)
  401.         {
  402.             if(pData[i][FACTION]==pData[playerid][FACTION]) SendClientMessage(i,-1,"Failed takeover!");
  403.             if(lastPointOwner[point]==pData[playerid][FACTION]) SendClientMessage(i,-1,"The attack has failed!");
  404.         }
  405.         takingPoint[point]=0;
  406.         GangZoneStopFlashForAll(capturePoint[point]);
  407.     }
  408.     return 1;
  409. }
  410. stock StartCapture(playerid,point)
  411. {
  412.     if(lastPointOwner[point]==pData[playerid][FACTION])return 0;
  413.     if(IsPlayerInAnyVehicle(playerid))return 0;
  414.     if(takingPoint[point]==0)
  415.     {
  416.         UpdatePointStatus(playerid,point,1);
  417.         timer[point] = SetTimerEx("SetZone",30000,false,"ii",playerid,point);
  418.     }
  419.     return 1;
  420. }
  421. public SetZone(playerid,point)
  422. {
  423.     if(GetPlayerState(playerid)==PLAYER_STATE_WASTED||IsPlayerInAnyVehicle(playerid))
  424.     {
  425.         if(ScanPointForAlly(playerid,point,0,0)==playerid)
  426.         {
  427.             UpdatePointStatus(playerid,point,0);
  428.             return 0;
  429.         }
  430.     }
  431.     GivePlayerMoney(ScanPointForAlly(playerid,point,1,1),1500);//double pay for solo capture
  432.     GivePlayerMoney(playerid,1500);
  433.     takingPoint[point]=0;
  434.     lastPointOwner[point]=pData[playerid][FACTION];
  435.     SendClientMessage(playerid, -1,"You've captured the zone and won $1500");
  436.     new string[64];
  437.     format(string,sizeof(string),"Capture Point %i has been taken over",point);
  438.     SendClientMessageToAll(-1,string);
  439.     GangZoneStopFlashForAll(point);
  440.     switch(pData[playerid][FACTION])
  441.     {
  442.         case FACTION_BALLAS: GangZoneShowForAll(capturePoint[point],COLOR_MAP_BALLAS);
  443.         case FACTION_GROVE: GangZoneShowForAll(capturePoint[point],COLOR_MAP_GROVE);
  444.         case FACTION_AZTECAS: GangZoneShowForAll(capturePoint[point],COLOR_MAP_AZTECAS);
  445.         case FACTION_MAFIA: GangZoneShowForAll(capturePoint[point],COLOR_MAP_MAFIA);
  446.     }
  447.     return 1;
  448. }
  449. stock IsPlayerInTurf(playerid)
  450. {
  451.     new Float:x,Float:y,Float:z;
  452.     GetPlayerPos(playerid,x,y,z);
  453.     for(new i;i<TOTAL_STURFS;i++)if(x >= stXY[i][MIN_X] && x <= stXY[i][MAX_X] && y >= stXY[i][MIN_Y] && y <= stXY[i][MAX_Y])return 1;
  454.     return 0;
  455. }
  456. stock ScanPointForAlly(playerid,point,entire,doReturn)
  457. {
  458.     new Float:x,Float:y,Float:z;
  459.     for(new i;i<MAX_PLAYERS;i++)
  460.     {
  461.         if(pData[playerid][FACTION]==pData[i][FACTION] && playerid!=i)
  462.         {
  463.             if(entire==0)
  464.             {
  465.                 if(IsPlayerInRangeOfPoint(i,5,pPos[point][pX],pPos[point][pY],pPos[point][pZ]))
  466.                 {
  467.                     if(doReturn==1) return i;
  468.                     else return 1;
  469.                 }
  470.             }
  471.             else
  472.             {
  473.                 GetPlayerPos(i,x,y,z);
  474.                 if(x >= cpXY[point][MIN_X] && x <= cpXY[point][MAX_X] && y >= cpXY[point][MIN_Y] && y <= cpXY[point][MAX_Y])
  475.                 {
  476.                     if(doReturn==1) return i;
  477.                     else return 1;
  478.                 }
  479.             }
  480.         }
  481.     }
  482.     return playerid;
  483. }
  484. //-------------------Y_INI functions----------------------------------
  485. public LoadpPos(tag[], name[], value[])
  486. {
  487.     for(new i;i<TOTAL_CPOINTS;i++)
  488.     {
  489.         new temp[4];
  490.         valstr(temp,i);
  491.         if (!strcmp(tag, temp))
  492.         {
  493.             if (!strcmp(name, "x")) pPos[i][pX]=floatstr(value);
  494.             if (!strcmp(name, "y")) pPos[i][pY]=floatstr(value);
  495.             if (!strcmp(name, "z")) pPos[i][pZ]=floatstr(value);
  496.         }
  497.     }
  498. }
  499. public Loadstxy(tag[], name[], value[])
  500. {
  501.     for(new i;i<TOTAL_STURFS;i++)
  502.     {
  503.         new temp[4];
  504.         valstr(temp,i);
  505.         if (!strcmp(tag, temp))
  506.         {
  507.             if (!strcmp(name, "minx")) stXY[i][MIN_X]=floatstr(value);
  508.             if (!strcmp(name, "miny")) stXY[i][MIN_Y]=floatstr(value);
  509.             if (!strcmp(name, "maxx")) stXY[i][MAX_X]=floatstr(value);
  510.             if (!strcmp(name, "maxy")) stXY[i][MAX_Y]=floatstr(value);
  511.         }
  512.     }
  513. }
  514. public Loadcpxy(tag[], name[], value[])
  515. {
  516.     for(new i;i<TOTAL_CPOINTS;i++)
  517.     {
  518.         new temp[4];
  519.         valstr(temp,i);
  520.         if (!strcmp(tag, temp))
  521.         {
  522.             if (!strcmp(name, "minx")) cpXY[i][MIN_X]=floatstr(value);
  523.             if (!strcmp(name, "miny")) cpXY[i][MIN_Y]=floatstr(value);
  524.             if (!strcmp(name, "maxx")) cpXY[i][MAX_X]=floatstr(value);
  525.             if (!strcmp(name, "maxy")) cpXY[i][MAX_Y]=floatstr(value);
  526.         }
  527.     }
  528. }
  529. public LoadPlayerData(playerid,tag[],name[],value[])
  530. {
  531.     new temp[4];
  532.     if (!strcmp(tag, "Basic"))
  533.     {
  534.         if (!strcmp(name, "Faction")) pData[playerid][FACTION]=strval(value);
  535.         if (!strcmp(name, "Class")) pData[playerid][CLASS]=strval(value);
  536.         if (!strcmp(name, "HasPlayed")) pData[playerid][HASPLAYED]=strval(value);
  537.         if (!strcmp(name, "Customized")) pData[playerid][CUSTOMIZED]=strval(value);
  538.  
  539.     }
  540.     if(pData[playerid][CUSTOMIZED]==1)
  541.     {
  542.         if (!strcmp(tag, "Weapons"))
  543.         {
  544.             for(new i;i<=12;i++)
  545.             {
  546.                 valstr(temp,i);
  547.                 if (!strcmp(name, temp)) pWeapons[playerid][i][0]=strval(value);
  548.             }
  549.         }
  550.         if (!strcmp(tag, "Ammo"))
  551.         {
  552.             for(new i;i<=12;i++)
  553.             {
  554.                 valstr(temp,i);
  555.                 if (!strcmp(name, temp)) pWeapons[playerid][i][1]=strval(value);
  556.             }
  557.         }
  558.     }
  559. }
  560. public SavePlayerData(playerid)
  561. {
  562.     new
  563.         userFile[64],
  564.         playerName[MAX_PLAYER_NAME],
  565.         tempWeps[13][2],
  566.         temp[13];
  567.     GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  568.     format(userFile, sizeof (userFile), "planetside/Users/%s.ini", playerName);
  569.     new
  570.         INI:ini = INI_Open(userFile);
  571.     //BASIC
  572.     INI_SetTag(ini, "Basic");
  573.     INI_WriteInt(ini, "Faction", pData[playerid][FACTION]);
  574.     INI_WriteInt(ini, "Class", pData[playerid][CLASS]);
  575.     INI_WriteInt(ini, "HasPlayed", pData[playerid][HASPLAYED]);
  576.     INI_WriteInt(ini, "Customized", pData[playerid][CUSTOMIZED]);
  577.     //WEAPONS&AMMO
  578.     for(new i;i<=12;i++) GetPlayerWeaponData(playerid, i, tempWeps[i][0], tempWeps[i][1]);
  579.     INI_SetTag(ini, "Weapons");
  580.     for(new i;i<=12;i++)
  581.     {
  582.         valstr(temp,i);
  583.         INI_WriteInt(ini, temp, tempWeps[i][0]);
  584.     }
  585.     INI_SetTag(ini, "Ammo");
  586.     for(new i;i<=12;i++)
  587.     {
  588.         valstr(temp,i);
  589.         INI_WriteInt(ini, temp, tempWeps[i][1]);
  590.     }
  591.     INI_Close(ini);
  592. }
  593. /*--------------------------------------------------------------
  594. ^^^^^^^^^^^^^^^
  595. END OF MY WORK
  596. ================================================================
  597. Rest is from wiki or forums
  598. vvvvvvvvvvvvvvvvv
  599. --------------------------------------------------------------*/
  600. stock SetPlayerSkinFix(playerid, skinid)
  601. {
  602.     new
  603.         Float:tmpPos[4],
  604.         vehicleid = GetPlayerVehicleID(playerid),
  605.         seatid = GetPlayerVehicleSeat(playerid);
  606.     GetPlayerPos(playerid, tmpPos[0], tmpPos[1], tmpPos[2]);
  607.     GetPlayerFacingAngle(playerid, tmpPos[3]);
  608.     if(skinid < 0 || skinid > 299) return 0;
  609.     if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
  610.     {
  611.         SetPlayerPos(playerid, tmpPos[0], tmpPos[1], tmpPos[2]);
  612.         SetPlayerFacingAngle(playerid, tmpPos[3]);
  613.         TogglePlayerControllable(playerid, 1);
  614.         return SetPlayerSkin(playerid, skinid);
  615.     }
  616.     else if(IsPlayerInAnyVehicle(playerid))
  617.     {
  618.         new tmp;
  619.         RemovePlayerFromVehicle(playerid);
  620.         SetPlayerPos(playerid, tmpPos[0], tmpPos[1], tmpPos[2]);
  621.         SetPlayerFacingAngle(playerid, tmpPos[3]);
  622.         TogglePlayerControllable(playerid, 1);
  623.         tmp = SetPlayerSkin(playerid, skinid);
  624.         PutPlayerInVehicle(playerid, vehicleid, (seatid == 128) ? 0 : seatid);
  625.         return tmp;
  626.     }
  627.     else
  628.     {
  629.         return SetPlayerSkin(playerid, skinid);
  630.     }
  631. }
  632. stock IsPlayerInWater(playerid)
  633. {
  634.     new animlib[32],tmp[32];
  635.     GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,tmp,32);
  636.     if( !strcmp(animlib, "SWIM") && !IsPlayerInAnyVehicle(playerid) ) return 1;
  637.     return 0;
  638. }
  639. //----------------------fin----------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment