[Ajuda] Salvamento de veнculos
#1

Pessoal fiz um cуdigo para os veнculos nascer na ъltima posiзгo que o player deixou ele.

Bom jб fiz como salvar agora quero fazer pro veнculo nascer na ultima posiзгo que o player deixou ele

pawn Код:
// Onplayerupdate
    new COR_1, COR_2, Veiculo, Float:Px, Float:Py, Float:Pz, Float:Angulo, STGV[256];
    Veiculo = GetPlayerVehicleID(playerid);
    GetVehiclePos(Veiculo, Px, Py, Pz);
    GetVehicleZAngle(Veiculo, Angulo);
    GetVehicleColor(Veiculo, COR_1, COR_2);
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(!DOF2_FileExists(STGV))
        {
            format(STGV, 100, "VEICULOS_SALVOS/ID_VEICULO_%d.ini", GetPlayerVehicleID(playerid));
            DOF2_CreateFile(STGV);
            DOF2_SetInt(STGV,"Modelo", GetVehicleModel(GetPlayerVehicleID(playerid)));
            DOF2_SetFloat(STGV,"PosX",Px);
            DOF2_SetFloat(STGV,"PosY",Py);
            DOF2_SetFloat(STGV,"PosZ",Pz);
            DOF2_SetFloat(STGV,"Angle",Angulo);
            DOF2_SetInt(STGV,"COR1",COR_1);
            DOF2_SetInt(STGV,"COR2",COR_2);
            DOF2_SaveFile();
        }
    }
meu ongamemodeinit.
pawn Код:
CivilVeiculo[0] = AddStaticVehicleEx(462, 1978.9014, -1274.5719, 23.3899, 180.4180, 1, 1, 300);
    CivilVeiculo[1] = AddStaticVehicleEx(462, 1981.6979, -1274.5699, 23.3896, 178.4302, 2, 2, 300);
    CivilVeiculo[2] = AddStaticVehicleEx(462, 1984.7279, -1274.5609, 23.3897, 178.2944, 3, 3, 300);
    CivilVeiculo[3] = AddStaticVehicleEx(462, 1987.6003, -1274.5469, 23.3906, 179.5856, 4, 4, 300);
    CivilVeiculo[4] = AddStaticVehicleEx(462, 1990.6230, -1274.5784, 23.3894, 181.2389, 5, 5, 300);
    CivilVeiculo[5] = AddStaticVehicleEx(462, 1993.5961, -1274.5565, 23.3892, 179.0403, 6, 6, 300);
    CivilVeiculo[6] = AddStaticVehicleEx(462, 1996.6348, -1274.6083, 23.3886, 179.0550, 7, 7, 300);
    CivilVeiculo[7] = AddStaticVehicleEx(462, 1999.3888, -1274.5767, 23.3888, 181.4814, 24, 24, 300);
    CivilVeiculo[8] = AddStaticVehicleEx(462, 2002.5083, -1274.5861, 23.3894, 179.3820, 86, 86, 300);
    CivilVeiculo[9] = AddStaticVehicleEx(462, 2005.3447, -1274.6067, 23.3936, 181.0860, 128, 128, 300);
    CivilVeiculo[10] = AddStaticVehicleEx(462, 2008.3119, -1274.5967, 23.3886, 182.4561, 183, 183, 300);

    GrooveVeiculo[0] = AddStaticVehicleEx(581, 2377.8347, -1699.7063, 13.1956, 89.5784, 16,16, 10800);
    GrooveVeiculo[1] = AddStaticVehicleEx(522, 2377.8743, -1701.5675, 13.1954, 88.2622, 16,16, 10800);
    GrooveVeiculo[2] = AddStaticVehicleEx(468, 2377.9700, -1703.3912, 13.3018, 93.8765, 16,16, 10800);
    GrooveVeiculo[3] = AddStaticVehicleEx(475, 2356.5120, -1701.6042, 13.4012, 269.1091, 16,16, 10800);
    GrooveVeiculo[4] = AddStaticVehicleEx(412, 2357.1597, -1705.6235, 13.4258, 268.1223, 16,16, 10800);
    GrooveVeiculo[5] = AddStaticVehicleEx(533, 2356.1941, -1709.7814, 13.2881, 268.3283, 16,16, 10800);
    GrooveVeiculo[6] = AddStaticVehicleEx(422, 2355.9980, -1713.8530, 13.5541, 267.9546, 16,16, 10800);
    GrooveVeiculo[7] = AddStaticVehicleEx(466, 2377.4822, -1711.5807, 13.3371, 89.1142, 16,16, 10800);
    GrooveVeiculo[8] = AddStaticVehicleEx(560, 2355.7544, -1718.6067, 13.2643, 269.5843, 16,16, 10800);
    GrooveVeiculo[9] = GrooveTexto =  AddStaticVehicleEx(413, 2385.0068, -1718.7528, 13.6636, 91.1600, 16,16, 10800);
    GrooveVeiculo[10] = AddStaticVehicleEx(487, 2384.3240, -1702.0944, 19.3458, 220.2840, 16,16, 10800);

    BallasVeiculo[0] = AddStaticVehicleEx(466, 659.8429, -1645.1439, 14.3081, 177.6864, 85,85, 10800);
    BallasVeiculo[1] = AddStaticVehicleEx(560, 670.5228, -1643.3558, 14.4079, 86.8164, 85,85, 10800);
    BallasVeiculo[2] = AddStaticVehicleEx(533, 670.2716, -1647.3403, 14.2027, 91.2701, 85,85, 10800);
    BallasVeiculo[3] = AddStaticVehicleEx(475, 669.9142, -1651.5248, 14.0099, 88.6091, 85,85, 10800);
    BallasVeiculo[4] = AddStaticVehicleEx(422, 669.9271, -1655.6644, 13.9243, 90.1961, 85,85, 10800);
    BallasVeiculo[5] = AddStaticVehicleEx(412, 669.1935, -1659.7954, 13.5561, 89.4399, 85,85, 10800);
    BallasVeiculo[6] = AddStaticVehicleEx(522, 651.0493, -1649.0388, 14.4169, 269.0190, 85,85, 10800);
    BallasVeiculo[7] = AddStaticVehicleEx(468, 651.0615, -1646.1985, 14.4351, 268.1945, 85,85, 10800);
    BallasVeiculo[8] = AddStaticVehicleEx(581, 650.9241, -1643.7020, 14.4954, 273.3327, 85,85, 10800);
    BallasVeiculo[9] = BallasTexto = AddStaticVehicleEx(413, 651.9084, -1632.8315, 15.1013, 180.6826, 85,85, 10800);
    BallasVeiculo[10] = AddStaticVehicleEx(487, 662.4856, -1635.5015, 20.8120, 235.1648, 85,85, 10800);

    AztecasVeiculo[0] = AddStaticVehicleEx(475, 1225.4344, -1009.5981, 32.7086, 278.0129, 2,2, 10800);
    AztecasVeiculo[1] = AddStaticVehicleEx(466, 1240.8612, -1004.2327, 32.1887, 98.6510, 2,2, 10800);
    AztecasVeiculo[2] = AddStaticVehicleEx(560, 1241.4324, -1008.1479, 32.3085, 96.2001, 2,2, 10800);
    AztecasVeiculo[3] = AddStaticVehicleEx(533, 1241.9584, -1011.8358, 32.3190, 96.4101, 2,2, 10800);
    AztecasVeiculo[4] = AddStaticVehicleEx(422, 1242.4010, -1015.5906, 32.2612, 93.4706, 2,2, 10800);
    AztecasVeiculo[5] = AddStaticVehicleEx(412, 1242.5725, -1019.6906, 32.3019, 96.3139, 2,2, 10800);
    AztecasVeiculo[6] = AddStaticVehicleEx(468, 1225.8643, -1018.3614, 32.1689, 276.1620, 2,2, 10800);
    AztecasVeiculo[7] = AddStaticVehicleEx(581, 1225.9906, -1020.2427, 32.1961, 268.9657, 2,2, 10800);
    AztecasVeiculo[8] = AddStaticVehicleEx(522, 1226.2628, -1022.1782, 32.1827, 272.0151, 2,2, 10800);
    AztecasVeiculo[9] = AztecasTexto = AddStaticVehicleEx(413,1238.8984,-1026.5271,32.3239,183.8933, 2,2, 10800);
    AztecasVeiculo[10] = AddStaticVehicleEx(487, 1218.2042, -1018.2147, 38.4099, 333.9951, 2,2, 10800);

    VagosVeiculo[0] = AddStaticVehicleEx(475, 2575.0400, -1027.1521, 69.6920, 176.3905, 6,6, 10800);
    VagosVeiculo[1] = AddStaticVehicleEx(422, 2578.8445, -1027.5051, 69.2319, 175.9995, 6,6, 10800);
    VagosVeiculo[2] = AddStaticVehicleEx(560, 2582.5295, -1027.9084, 69.2761, 174.8300, 6,6, 10800);
    VagosVeiculo[3] = AddStaticVehicleEx(466, 2586.3906, -1028.4574, 69.1590, 174.1256, 6,6, 10800);
    VagosVeiculo[4] = AddStaticVehicleEx(581, 2570.8296, -1038.4465, 69.1706, 268.0432, 6,6, 10800);
    VagosVeiculo[5] = AddStaticVehicleEx(468, 2570.7930, -1040.1599, 69.1427, 272.6797, 6,6, 10800);
    VagosVeiculo[6] = AddStaticVehicleEx(522, 2570.8232, -1041.8363, 69.1585, 270.9237, 6,6, 10800);
    VagosVeiculo[7] = AddStaticVehicleEx(533, 2579.0476, -1053.1356, 69.3162, 269.8736, 6,6, 10800);
    VagosVeiculo[8] = AddStaticVehicleEx(412, 2589.1189, -1053.4136, 69.2417, 267.8491, 6,6, 10800);
    VagosVeiculo[9] = VagosTexto = AddStaticVehicleEx(413, 2590.3257, -1039.5934, 69.6637, 176.4394, 6,6, 10800);
    VagosVeiculo[10] = AddStaticVehicleEx(487, 2562.1636, -1037.0720, 75.3100, 330.2671, 6,6, 10800);

    PMVeiculo[0] = AddStaticVehicleEx(497, 1556.4930, -1611.6489, 13.5634, 238.1501, 53, 7, 10800);
    PMVeiculo[1] = AddStaticVehicleEx(523, 1599.7970, -1687.7898, 5.4549, 93.4757, 53, 7, 10800);
    PMVeiculo[2] = AddStaticVehicleEx(523, 1599.8687, -1684.0831, 5.4559, 90.2163, 53, 7, 10800);
    PMVeiculo[3] = AddStaticVehicleEx(523, 1599.8081, -1691.9186, 5.4550, 91.2976, 53, 7, 10800);
    PMVeiculo[4] = AddStaticVehicleEx(599, 1601.0620, -1700.0439, 6.0899, 87.8677, 53, 7, 10800);
    PMVeiculo[5] = AddStaticVehicleEx(599, 1558.3602, -1710.2605, 6.0807, 0.8976, 53, 7, 10800);
    PMVeiculo[6] = AddStaticVehicleEx(599, 1566.6609, -1710.1411, 6.0804, 359.6317, 53, 7, 10800);
    PMVeiculo[7] = AddStaticVehicleEx(596, 1578.5453, -1710.1051, 5.6131, 358.9399, 53, 7, 10800);
    PMVeiculo[8] = AddStaticVehicleEx(596, 1574.5531, -1710.0419, 5.6151, 0.5515, 53, 7, 10800);
    PMVeiculo[9] = PMTexto = AddStaticVehicleEx(427, 1595.4957, -1710.8848, 6.0255, 0.9270, 53, 7, 10800);
    PMVeiculo[10] = AddStaticVehicleEx(596, 1570.3380, -1710.0854, 5.6130, 359.7447, 53, 7, 10800);

    SetVehicleVirtualWorld(AddStaticVehicleEx(445, -2517.1057, 1229.3579, 37.3041, 210.8749, 10, 14, 300), 1);
    SetVehicleVirtualWorld(AddStaticVehicleEx(549, -2521.6111, 1229.6517, 37.1187, 211.9417, 29, 21, 300), 1);
    SetVehicleVirtualWorld(AddStaticVehicleEx(436, -2526.1528, 1229.6345, 37.1987, 209.5399, 53, 27, 300), 1);
    SetVehicleVirtualWorld(AddStaticVehicleEx(542, -2530.3452, 1229.3582, 37.1727, 211.8901, 52, 64, 300), 1);
    SetVehicleVirtualWorld(AddStaticVehicleEx(421, -2534.7693, 1229.6210, 37.3055, 213.3364, 59, 100, 300), 1);
    SetVehicleVirtualWorld(AddStaticVehicleEx(458, -2538.7791, 1229.0923, 37.3036, 212.1581, 48, 61, 300), 1);

    SetVehicleVirtualWorld(AddStaticVehicleEx(522, -2517.1057, 1229.3579, 37.3041, 210.8749, 10, 14, 300), 2);
    SetVehicleVirtualWorld(AddStaticVehicleEx(586, -2521.6111, 1229.6517, 37.1187, 211.9417, 29, 21, 300), 2);
    SetVehicleVirtualWorld(AddStaticVehicleEx(581, -2526.1528, 1229.6345, 37.1987, 209.5399, 53, 27, 300), 2);
    SetVehicleVirtualWorld(AddStaticVehicleEx(463, -2530.3452, 1229.3582, 37.1727, 211.8901, 52, 64, 300), 2);
    SetVehicleVirtualWorld(AddStaticVehicleEx(461, -2534.7693, 1229.6210, 37.3055, 213.3364, 59, 100, 300), 2);
    SetVehicleVirtualWorld(AddStaticVehicleEx(521, -2538.7791, 1229.0923, 37.3036, 212.1581, 48, 61, 300), 2);

    SetVehicleVirtualWorld(AddStaticVehicleEx(578, -2534.0417, 1228.2731, 38.0480, 212.3052, 31, 120, 300), 3);
    SetVehicleVirtualWorld(AddStaticVehicleEx(403, -2525.6074, 1228.7081, 38.0370, 210.2109, 15, 127, 300), 3);
    SetVehicleVirtualWorld(AddStaticVehicleEx(433, -2516.6614, 1228.4393, 37.8750, 213.3337, 64, 47, 300), 3);
    SetVehicleVirtualWorld(AddStaticVehicleEx(431, -2517.5986, 1214.6699, 37.5316, 270.5688, 45, 112, 300), 3);
    SetVehicleVirtualWorld(AddStaticVehicleEx(437, -2510.8037, 1210.0028, 37.5589, 270.3356, 57, 27, 300), 3);
    SetVehicleVirtualWorld(AddStaticVehicleEx(431, -2511.1392, 1205.3821, 37.5264, 269.4654, 29, 24, 300), 3);

    SetVehicleVirtualWorld(AddStaticVehicleEx(473, 2349.5532, 519.0534, -0.3944, 178.3051, 82, 94, 300), 4);
    SetVehicleVirtualWorld(AddStaticVehicleEx(473, 2354.4417, 519.0881, -0.3245, 181.6989, 83, 95, 300), 4);
    SetVehicleVirtualWorld(AddStaticVehicleEx(473, 2358.7117, 518.9028, -0.3568, 181.4837, 84, 96, 300), 4);
    SetVehicleVirtualWorld(AddStaticVehicleEx(473, 2362.5864, 518.5739, -0.3699, 179.2757, 85, 97, 300), 4);
    SetVehicleVirtualWorld(AddStaticVehicleEx(473, 2366.4617, 518.7509, -0.3097, 181.3149, 124, 112, 300), 4);
    SetVehicleVirtualWorld(AddStaticVehicleEx(473, 2370.0757, 519.0974, -0.2546, 185.9216, 264, 421, 300), 4);

    SetVehicleVirtualWorld(AddStaticVehicleEx(487, 1318.3221, 1557.8464, 11.0218, 357.2314, 19, 88, 300), 5);
    SetVehicleVirtualWorld(AddStaticVehicleEx(487, 1327.8663, 1557.4504, 10.9948, 358.6094, 29, 78, 300), 5);
    SetVehicleVirtualWorld(AddStaticVehicleEx(487, 1337.2073, 1557.5336, 10.9718, 358.3448, 39, 68, 300), 5);
    SetVehicleVirtualWorld(AddStaticVehicleEx(487, 1348.4108, 1557.0514, 10.9609, 359.1650, 49, 58, 300), 5);
    SetVehicleVirtualWorld(AddStaticVehicleEx(487, 1350.0757, 1626.9108, 10.9988, 177.0677, 59, 48, 300), 5);
    SetVehicleVirtualWorld(AddStaticVehicleEx(487, 1339.1368, 1626.9711, 10.9724, 178.6447, 69, 38, 300), 5);
Reply
#2

Pra comeзar nгo pode usar OnPlayerUpdate para salvar esses dados xD

Depois o seu sistema de stand devera ser dinamico, ou seja, melhor colocar os veнculos para spawnarem dentro do servidor por comando, para ser mais fбcil salvar a pуs e voltar a carregar-la.
Reply
#3

Quote:
Originally Posted by PT
Посмотреть сообщение
Pra comeзar nгo pode usar OnPlayerUpdate para salvar esses dados xD

Depois o seu sistema de stand devera ser dinamico, ou seja, melhor colocar os veнculos para spawnarem dentro do servidor por comando, para ser mais fбcil salvar a pуs e voltar a carregar-la.
Entгo meu caro, como meu servidor й RP/G. Entгo ficarб ruim. os players nгo irгo digitar um comando para salvar o veнculo. serб um ant rpg.
Reply
#4

Nao й isso cara.

exemplo: /criarcarro modelo cor1 cor2 tipo

ai no tipo voce especifica para o que й se й para a polica, ou outra coisa.

Ai salva na base de dados, quando o servidor reiniciar salva a pos de todos os carros na base de dados e quando ele voltar ele carregara eles de volta.

Se quiser que seja ao disconnectar a logica й a mesma, so que quando o player disconnecta.
Reply
#5

Quote:
Originally Posted by PT
Посмотреть сообщение
Nao й isso cara.

exemplo: /criarcarro modelo cor1 cor2 tipo

ai no tipo voce especifica para o que й se й para a polica, ou outra coisa.

Ai salva na base de dados, quando o servidor reiniciar salva a pos de todos os carros na base de dados e quando ele voltar ele carregara eles de volta.

Se quiser que seja ao disconnectar a logica й a mesma, so que quando o player disconnecta.
coloquei pra salvar em onplayerdisconnect, certo

agora pra carregar vou fazer assim й melhor nй

pawn Код:
for(new i ; i < MAX_VEHICLES ; ++i)
    {
        format ( String , sizeof ( String ) , "VEICULOS_SALVOS/Veiculo(%d).ini" , i ) ;
        if(DOF2_FileExists(String))
        {
            if(i == 0)
            {
                GrooveVeiculo[0] = AddStaticVehicleEx(DOF2_GetInt(String,"MODELO"), DOF2_GetFloat(String,"PosX"), DOF2_GetFloat(String,"PosY"), DOF2_GetFloat(String,"PosZ"), DOF2_GetFloat(String,"Angle"), DOF2_GetInt(String,"COR1"), DOF2_GetInt(String,"COR2"), 10800);
            }
            else
            {
                GrooveVeiculo[0] = AddStaticVehicleEx(581, 2377.8347, -1699.7063, 13.1956, 89.5784, 16,16, 10800);
            }
            if(i == 1)
            {
                GrooveVeiculo[1] = AddStaticVehicleEx(DOF2_GetInt(String,"MODELO"), DOF2_GetFloat(String,"PosX"), DOF2_GetFloat(String,"PosY"), DOF2_GetFloat(String,"PosZ"), DOF2_GetFloat(String,"Angle"), DOF2_GetInt(String,"COR1"), DOF2_GetInt(String,"COR2"), 10800);
            }
            else
            {
                GrooveVeiculo[1] = AddStaticVehicleEx(581, 2377.8347, -1699.7063, 13.1956, 89.5784, 16,16, 10800);
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)