Szerző Téma: Jármû kérdés  (Megtekintve 885 alkalommal)

Jármû kérdés
« Dátum: 2014. február 13. - 21:34:01 »
0 Show voters
Minap megpróbáltam tutorialok segítségével összehozni egy MySQL-n alapuló regisztrációs és jármû rendszert. A regisztrálás,adatmentés, jármû mentés az adatbázisba sikerült, de nem tudom, hogyan kellene belekezdenem abba, hogy ha szerver leáll akkor az adatbázisba mentett jármûveket leellenõrizze és az új adatokkal (koordináta, szín) elraktározza.
Jármû részleg:
 
new DynamicCarID[MAX_VEHICLES], DynamicCar[MAX_VEHICLES], DynamicCarCol[MAX_VEHICLES][3];
new VehicleNames[][] =
{
    \"Landstalker\", \"Bravura\", \"Buffalo\", \"Linerunner\", \"Perrenial\", \"Sentinel\",
    \"Dumper\", \"Firetruck\", \"Trashmaster\", \"Stretch\", \"Manana\", \"Infernus\",
    \"Voodoo\", \"Pony\", \"Mule\", \"Cheetah\", \"Ambulance\", \"Leviathan\", \"Moonbeam\",
    \"Esperanto\", \"Taxi\", \"Washington\", \"Bobcat\", \"Whoopee\", \"BF Injection\",
    \"Hunter\", \"Premier\", \"Enforcer\", \"Securicar\", \"Banshee\", \"Predator\", \"Bus\",
    \"Rhino\", \"Barracks\", \"Hotknife\", \"Trailer\", \"Previon\", \"Coach\", \"Cabbie\",
    \"Stallion\", \"Rumpo\", \"RC Bandit\", \"Romero\", \"Packer\", \"Monster\", \"Admiral\",
    \"Squalo\", \"Seasparrow\", \"Pizzaboy\", \"Tram\", \"Trailer\", \"Turismo\", \"Speeder\",
    \"Reefer\", \"Tropic\", \"Flatbed\", \"Yankee\", \"Caddy\", \"Solair\", \"Berkley\'s RC Van\",
    \"Skimmer\", \"PCJ-600\", \"Faggio\", \"Freeway\", \"RC Baron\", \"RC Raider\", \"Glendale\",
    \"Oceanic\",\"Sanchez\", \"Sparrow\", \"Patriot\", \"Quad\", \"Coastguard\", \"Dinghy\",
    \"Hermes\", \"Sabre\", \"Rustler\", \"ZR-350\", \"Walton\", \"Regina\", \"Comet\", \"BMX\",
    \"Burrito\", \"Camper\", \"Marquis\", \"Baggage\", \"Dozer\", \"Maverick\", \"News Chopper\",
    \"Rancher\", \"FBI Rancher\", \"Virgo\", \"Greenwood\", \"Jetmax\", \"Hotring\", \"Sandking\",
    \"Blista Compact\", \"Police Maverick\", \"Boxville\", \"Benson\", \"Mesa\", \"RC Goblin\",
    \"Hotring Racer A\", \"Hotring Racer B\", \"Bloodring Banger\", \"Rancher\", \"Super GT\",
    \"Elegant\", \"Journey\", \"Bike\", \"Mountain Bike\", \"Beagle\", \"Cropduster\", \"Stunt\",
    \"Tanker\", \"Roadtrain\", \"Nebula\", \"Majestic\", \"Buccaneer\", \"Shamal\", \"Hydra\",
    \"FCR-900\", \"NRG-500\", \"HPV1000\", \"Cement Truck\", \"Tow Truck\", \"Fortune\",
    \"Cadrona\", \"FBI Truck\", \"Willard\", \"Forklift\", \"Tractor\", \"Combine\", \"Feltzer\",
    \"Remington\", \"Slamvan\", \"Blade\", \"Freight\", \"Streak\", \"Vortex\", \"Vincent\",
    \"Bullet\", \"Clover\", \"Sadler\", \"Firetruck\", \"Hustler\", \"Intruder\", \"Primo\",
    \"Cargobob\", \"Tampa\", \"Sunrise\", \"Merit\", \"Utility\", \"Nevada\", \"Yosemite\",
    \"Windsor\", \"Monster\", \"Monster\", \"Uranus\", \"Jester\", \"Sultan\", \"Stratium\",
    \"Elegy\", \"Raindance\", \"RC Tiger\", \"Flash\", \"Tahoma\", \"Savanna\", \"Bandito\",
    \"Freight Flat\", \"Streak Carriage\", \"Kart\", \"Mower\", \"Dune\", \"Sweeper\",
    \"Broadway\", \"Tornado\", \"AT-400\", \"DFT-30\", \"Huntley\", \"Stafford\", \"BF-400\",
    \"News Van\", \"Tug\", \"Trailer\", \"Emperor\", \"Wayfarer\", \"Euros\", \"Hotdog\", \"Club\",
    \"Freight Box\", \"Trailer\", \"Andromada\", \"Dodo\", \"RC Cam\", \"Launch\", \"LSPD Cruiser\",
    \"SFPD Cruiser\", \"LVPD Cruiser\", \"Police Ranger\", \"Picador\", \"S.W.A.T\", \"Alpha\",
    \"Phoenix\", \"Glendale\", \"Sadler\", \"Luggage\", \"Luggage\", \"Stairs\", \"Boxville\",
    \"Tiller\", \"Utility Trailer\"
};
command(savecar, playerid, params[])
{
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                new Float:x, Float:y, Float:z, Float:a, mod = GetVehicleModel(GetPlayerVehicleID(playerid)), col1, col2, pl[9], vehicleid = GetPlayerVehicleID(playerid), string[128];
                if(sscanf(params, \"iis[8]\", col1, col2, pl))return SendClientMessage(playerid, -1, \"Használat: /savecar [szín 1] [szín 2] [rendszám]\");
                {
                    if(strlen(pl) > 8)return SendClientMessage(playerid, -1, \"8 karakternél rövidebb legyen a rendszám.\");
                    GetVehiclePos(vehicleid, x, y, z);
                    GetVehicleZAngle(vehicleid, a);
                    SaveDynamicVehicle(x, y, z, a, mod, col1, col2, pl);
                    SetVehicleNumberPlate(vehicleid, pl);
                    SetVehicleToRespawn(vehicleid);
                    SetVehiclePos(vehicleid, x, y, z);
                    SetVehicleZAngle(vehicleid, a);
                    ChangeVehicleColor(vehicleid, col1, col2);
                    format(string, sizeof(string), \"Elmentetted %s -t adatbázisba. Színek: %s és %s, rendszám: %s.\", GetVehicleName(vehicleid), GetVehicleColorName(col1), GetVehicleColorName(col2), pl);
                    SendClientMessage(playerid, -1, string);
                }
            }
            else return SendClientMessage(playerid, -1, \"Neked kell lenned a sofõrnek.\");
        }
        else return SendClientMessage(playerid, -1, \"Szállj be egy jármûbe.\");
        return 1;
}
stock SaveDynamicVehicle(Float:x, Float:y, Float:z, Float:a, mod, c1, c2, plate[])
{
        new Query[512];
        format(Query, sizeof(Query), \"INSERT INTO `dynamicvehicles` (model, x, y, z, a, c1, c2, plate) VALUES(%d, %f, %f, %f, %f, %i, %i, \'%s\')\",
        mod, x, y, z, a, c1, c2, plate);
        mysql_tquery(mysql, Query, \"\", \"\");
        mysql_free_result();
        return 1;
}
stock LoadDynamicVehicles()
{
//new query[900];
new Str[128], VehicleID, VehicleModel, Float:VehicleX, Float:VehicleY, Float:VehicleZ, Float:VehicleA, Col1, Col2, vehPlate[10], i = 0;
    //mysql_format(mysql, query, sizeof(query),\"SELECT * FROM `dynamicvehicles`\");
      //mysql_query(\"SELECT * FROM `dynamicvehicles`\");
      mysql_query(mysql, \"SELECT * FROM `dynamicvehicles`\");
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, \"p<|>iiffffiis[10]\", VehicleID, VehicleModel, VehicleX, VehicleY, VehicleZ, VehicleA, Col1, Col2, vehPlate);
            CreateVehicle(VehicleModel, VehicleX, VehicleY, VehicleZ, VehicleA, Col1, Col2, -1);
   SetVehicleNumberPlate(i, vehPlate);
            SetVehicleToRespawn(i);
            DynamicCarID = VehicleID;
            DynamicCarCol[1] = Col1;
            DynamicCarCol[2] = Col2;
            DynamicCar = 1;
            i++;
}
    }
    mysql_free_result();
    printf(\"--- %i jármû betöltve az adatbázisból. ---\", i);
    return 1;
}
stock GetVehicleName(vehicleid)
{
new String[28];
    format(String,sizeof(String),\"%s\",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return String;
}
stock GetVehicleColorName(color)
{
    new clr[32];
    switch(color)
    {
        case 0: clr =\"Black\";
        case 1: clr =\"White\";
        case 2: clr =\"Blue\";
        case 3: clr =\"Red\";
        case 4: clr =\"Grey-Green\";
        case 5: clr =\"Purple\";
        case 6: clr =\"Yellow\";
        case 7: clr =\"Blue\";
        case 8: clr =\"Silver\";
        case 9: clr =\"Dark sGrey\";
        case 10: clr =\"Midnight Blue\";
        case 11: clr =\"Dark Grey\";
        case 12: clr =\"Teal\";
        case 13: clr =\"Dark Grey\";
        case 14: clr =\"Light Grey\";
        case 15: clr =\"Silver\";
        case 16: clr =\"Dark Green\";
        case 17: clr =\"Dark Red\";
        case 18: clr =\"Dark Red\";
        case 19: clr =\"Grey\";
        case 20: clr =\"Royal Blue\";
        case 21: clr =\"Rich Maroon\";
        case 22: clr =\"Rich Maroon\";
        case 23: clr =\"Grey\";
        case 24: clr =\"Dark Grey\";
        case 25: clr =\"Dark Grey\";
        case 26: clr =\"Light Grey\";
        case 27: clr =\"Grey\";
        case 28: clr =\"Midnight Blue\";
        case 29: clr =\"Light Grey\";
        case 30: clr =\"Dark Maroon\";
        case 31: clr =\"Red\";
        case 32: clr =\"Baby Blue\";
        case 33: clr =\"Grey\";
        case 34: clr =\"Grey\";
        case 35: clr =\"Dark Grey\";
        case 36: clr =\"Dark Grey\";
        case 37: clr =\"\";
        case 38: clr =\"Tea Green\";
        case 39: clr =\"Steel blue\";
        case 40: clr =\"Black\";
        case 41: clr =\"Light Brown\";
        case 42: clr =\"Bright Maroon\";
        case 43: clr =\"Maroon\";
        case 44: clr =\"Myrtle Green\";
        case 45: clr =\"Maroon\";
        case 46: clr =\"Olive Green\";
        case 47: clr =\"Olive\";
        case 48: clr =\"Khaki Brown\";
        case 49: clr =\"Light Grey\";
        case 50: clr =\"Silver Grey\";
        case 51: clr =\"Dark Green\";
        case 52: clr =\"Dark Teal\";
        case 53: clr =\"Navy Blue\";
        case 54: clr =\"Navy Blue\";
        case 55: clr =\"Brown\";
        case 56: clr =\"Light Grey\";
        case 57: clr =\"Beige\";
        case 58: clr =\"Maroon\";
        case 59: clr =\"Grey-Blue\";
        case 60: clr =\"Grey\";
        case 61: clr =\"Old Gold\";
        case 62: clr =\"Maroon\";
        case 63: clr =\"Grey\";
        case 64: clr =\"Grey\";
        case 65: clr =\"Old Gold\";
        case 66: clr =\"Dark Brown\";
        case 67: clr =\"Light Blue\";
        case 68: clr =\"Light Khaki\";
        case 69: clr =\"Light Pink\";
        case 70: clr =\"Bright Maroon\";
        case 71: clr =\"Light Blue\";
        case 72: clr =\"Grey\";
        case 73: clr =\"Tea Green\";
        case 74: clr =\"Dark Maroon\";
        case 75: clr =\"Dark Blue\";
        case 76: clr =\"Light Brown\";
        case 77: clr =\"Ecru Brown\";
        case 78: clr =\"Maroon\";
        case 79: clr =\"Royal Blue\";
        case 80: clr =\"Rich Maroon\";
        case 81: clr =\"Light Brown\";
        case 82: clr =\"Bright Maroon\";
        case 83: clr =\"Dark Teal Green\";
        case 84: clr =\"Brown\";
        case 85: clr =\"Rich Maroon\";
        case 86: clr =\"Green\";
        case 87: clr =\"Blue \";
        case 88: clr =\"Maroon\";
        case 89: clr =\"Beige\";
        case 90: clr =\"Grey\";
        case 91: clr =\"Dark Blue\";
        case 92: clr =\"Grey\";
        case 93: clr =\"Sky Blue\";
        case 94: clr =\"Blue\";
        case 95: clr =\"Navy Blue\";
        case 96: clr =\"Silver\";
        case 97: clr =\"Light Blue\";
        case 98: clr =\"Grey\";
        case 99: clr =\"Light Brown \";
        case 100: clr =\"Blue\";
        case 101: clr =\"Dark Blue\";
        case 102: clr =\"Light Brown\";
        case 103: clr =\"Blue\";
        case 104: clr =\"Brown\";
        case 105: clr =\"Dark Grey\";
        case 106: clr =\"Blue\";
        case 107: clr =\"Light Brown\";
        case 108: clr =\"Yale Blue\";
        case 109: clr =\"Dark Grey\";
        case 110: clr =\"Brown\";
        case 111: clr =\"Light Grey\";
        case 112: clr =\"Blue\";
        case 113: clr =\"Brown\";
        case 114: clr =\"Dark Grey\";
        case 115: clr =\"Dark Red\";
        case 116: clr =\"Navy Blue\";
        case 117: clr =\"Dark Maroon\";
        case 118: clr =\"Light Blue\";
        case 119: clr =\"Brown\";
        case 120: clr =\"Light Brown\";
        case 121: clr =\"Dark Maroon\";
        case 122: clr =\"Grey\";
        case 123: clr =\"Brown\";
        case 124: clr =\"Rich Maroon\";
        case 125: clr =\"Dark Blue\";
        case 126: clr =\"Pink\";
    }
    return clr;
}

Nem elérhető ZyZu.

  • Globális moderátor
  • 8939
  • my turbo diesel forum
  • Discord: ZyZu.
    • Profil megtekintése
Jármû kérdés
« Válasz #1 Dátum: 2014. február 13. - 21:43:11 »
0 Show voters
OnGameModeExit -nél lementesz minden jármûvet és kész.. ha erre gondoltál hol/merre kéne menteni?

Jármû kérdés
« Válasz #2 Dátum: 2014. február 13. - 22:04:34 »
0 Show voters
Én is azt akarom megvalósítani, de egyszerûen nem jön az ihlet, hogyan is kéne belekezdenem, hogy kérjem le minden jármû pozícióját és helyezzem be egyesével az adatbázisba a megfelelõ azonosítóhoz

Nem elérhető ZyZu.

  • Globális moderátor
  • 8939
  • my turbo diesel forum
  • Discord: ZyZu.
    • Profil megtekintése
Jármû kérdés
« Válasz #3 Dátum: 2014. február 14. - 00:10:09 »
0 Show voters

Nem elérhető Pedró

  • 3341
  • 2014 © Az év Szkriptere
    • Profil megtekintése
Jármû kérdés
« Válasz #4 Dátum: 2014. február 17. - 06:18:50 »
0 Show voters
OnGameModeExit alá. (Egyébként az OnGameModeExit nem fog meghívódni, ha nem \"exit-eled\" a szervert.. Viszont ezt nem fejtem ki, olvass utána. :p
 
stock UpdateVehicleDatas() {
new Query[512], Float:x, Float:y, Float:z, Float:a;
for(new i; i < MAX_VEHICLES; i++) {
    if(!DynamicCar) continue;
                GetVehiclePos(i, x, y, z);
                GetVehicleZAngle(i, a);
format(Query, sizeof(Query), \"UPDATE `dynamicvehicles` SET x = \'%f\', y = \'%f\', z = \'%f\', a = \'%f\' WHERE id = \'%i\';\", x, y, z, a, DynamicCarID);
mysql_tquery(mysql, Query, \"\", \"\");
}
}
« Utoljára szerkesztve: 2014. február 17. - 06:20:30 írta Pedró »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal