Vehicle Spawn Script geht nach Überarbeitung nicht

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Hi Leute,
    ich habe dieses Filterscript zum Autos spawnen ein wenig umgeschrieben, sodass der Spieler beim Spawnen im Auto sitzt und das Kennzeichen anders ist. Beides habe ich bereits geschafft, aber die Verbindung aus beidem funktioniert nicht. Es werden keine Fehler oder Warns angezeigt, aber trotzdem tritt keine der Änderungen in Kraft.
    Hier das modifizierte Script:
    //Das ist ein Fahrzeug Spawner Filterscript
    //Tuhe das in den Ordner Filterscripts
    //Füge VehicleSpawner in der server.cfg hinzu
    //und starte deinen samp server


    #include <a_samp>


    #define MIN_VEHI_ID 400
    #define MAX_VEHI_ID 611
    #define COLOR_RED 0xFF4040FF
    #define COLOR_GREEN 0x40FF40FF
    #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
    new bool:vspawn[MAX_PLAYERS];
    new curPlayerVehM[MAX_PLAYERS] = {MIN_VEHI_ID, ...};
    new curPlayerVehI[MAX_PLAYERS] = {-1, ...};
    forward ToggleSpawn(playerid);


    new aVehicleNames[212][] = {
    {"Landstalker"},
    {"Bravura"},
    {"Buffalo"},
    {"Linerunner"},
    {"Perrenial"},
    {"Sentinel"},
    {"Dumper"},
    {"Firetruck"},
    {"Trashmaster"},
    {"Stretch"},
    {"Manana"},
    {"Infernus"},
    {"Voodoo"},
    {"Pony"},
    {"Mule"},
    {"Cheetah"},
    {"Ambulance"},
    {"Leviathan"},
    {"Moonbeam"},
    {"Esperanto"},
    {"Taxi"},
    {"Washington"},
    {"Bobcat"},
    {"Mr Whoopee"},
    {"BF Injection"},
    {"Hunter"},
    {"Premier"},
    {"Enforcer"},
    {"Securicar"},
    {"Banshee"},
    {"Predator"},
    {"Bus"},
    {"Rhino"},
    {"Barracks"},
    {"Hotknife"},
    {"Trailer 1"},
    {"Previon"},
    {"Coach"},
    {"Cabbie"},
    {"Stallion"},
    {"Rumpo"},
    {"RC Bandit"},
    {"Romero"},
    {"Packer"},
    {"Monster"},
    {"Admiral"},
    {"Squalo"},
    {"Seasparrow"},
    {"Pizzaboy"},
    {"Tram"},
    {"Trailer 2"},
    {"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"},
    {"Hotrina"},
    {"Hotrinb"},
    {"Bloodring Banger"},
    {"Rancher"},
    {"Super GT"},
    {"Elegant"},
    {"Journey"},
    {"Bike"},
    {"Mountain Bike"},
    {"Beagle"},
    {"Cropdust"},
    {"Stunt"},
    {"Tanker"}, //petro
    {"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 LA"}, //firela
    {"Hustler"},
    {"Intruder"},
    {"Primo"},
    {"Cargobob"},
    {"Tampa"},
    {"Sunrise"},
    {"Merit"},
    {"Utility"},
    {"Nevada"},
    {"Yosemite"},
    {"Windsor"},
    {"MonsterA"},
    {"MonsterB"},
    {"Uranus"},
    {"Jester"},
    {"Sultan"},
    {"Stratum"},
    {"Elegy"},
    {"Raindance"},
    {"RC Tiger"},
    {"Flash"},
    {"Tahoma"},
    {"Savanna"},
    {"Bandito"},
    {"Freight Flat"},
    {"Streak Carriage"},
    {"Kart"},
    {"Mower"},
    {"Duneride"},
    {"Sweeper"},
    {"Broadway"},
    {"Tornado"},
    {"AT-400"},
    {"DFT-30"},
    {"Huntley"},
    {"Stafford"},
    {"BF-400"},
    {"Newsvan"},
    {"Tug"},
    {"Trailer3"},
    {"Emperor"},
    {"Wayfarer"},
    {"Euros"},
    {"Hotdog"},
    {"Club"},
    {"Freight Carriage"},
    {"Trailer3"},
    {"Andromada"},
    {"Dodo"},
    {"RCCam"},
    {"Launch"},
    {"Police CarLSP)"},
    {"Police CarSFPD"},
    {"Police CarLVPD"},
    {"Police Ranger"},
    {"Picador"},
    {"SWATVAN"},
    {"Alpha"},
    {"Phoenix"},
    {"Glendale"},
    {"Sadler"},
    {"Luggage Trailer A"},
    {"Luggage Trailer B"},
    {"Stair Trailer"},
    {"Boxville"},
    {"Farm Plow"},
    {"Utility Trailer"}
    };



    enum CURVEHICLE {
    bool:spawn,
    vmodel,
    vInt
    };
    new curServerVehP[MAX_VEHICLES][CURVEHICLE];


    public OnPlayerConnect(playerid) {
    vspawn[playerid] = true;
    }
    public OnPlayerCommandText(playerid, cmdtext[])
    {
    dcmd(v, 1, cmdtext);
    return 0;
    }


    dcmd_v(playerid, params[]) {
    new idx, iString[128];
    iString = strtok(params, idx);



    if (!strlen(iString)) {
    SendClientMessage(playerid, COLOR_GREEN, "USE: /v ID/NAME");
    return true;
    }


    idx = GetVehicleModelIDFromName(params[1]);


    if(idx == -1) {
    idx = strval(iString);


    if (idx < MIN_VEHI_ID || idx > MAX_VEHI_ID) {
    SendClientMessage(playerid, COLOR_GREEN, "ERROR: UNKNOWN NAME");
    return true;
    }
    }


    if (vspawn[playerid] == true) {
    new Float:x, Float:y, Float:z, Float:a;


    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);


    curPlayerVehM[playerid] = idx;

    new String[128];
    format(String, 32, "PSX - %s ",GetPlayerInterior(playerid));
    curPlayerVehI[playerid] = CreateVehicle(idx, x, y, z + 2.0, a + 90.0, -1, -1, 90);
    vspawn[playerid] = false;
    SetTimerEx("ToggleSpawn", 60000, false,"e",playerid);
    LinkVehicleToInterior(curPlayerVehI[playerid], GetPlayerInterior(playerid));


    curServerVehP[curPlayerVehI[playerid]][spawn] = true;
    curServerVehP[curPlayerVehI[playerid]][vmodel] = idx;
    curServerVehP[curPlayerVehI[playerid]][vInt] = GetPlayerInterior(playerid);
    SetVehicleNumberPlate(GetPlayerInterior(playerid), String);
    SetVehicleToRespawn(GetPlayerInterior(playerid));
    PutPlayerInVehicle(playerid, GetPlayerInterior(playerid), 0);


    format(iString, 128, "[SUCCESS]: You spawned \"%s\" (ID: %d, VEHICLE ID: %d)", aVehicleNames[idx - MIN_VEHI_ID], idx, curPlayerVehI[playerid]);


    SendClientMessage(playerid, COLOR_GREEN, iString);
    } else {
    new Float:x, Float:y, Float:z, Float:a;


    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);


    curPlayerVehM[playerid] = idx;


    new String[128];
    format(String, 32, "PSX - %s ",GetPlayerInterior(playerid));
    curPlayerVehI[playerid] = CreateVehicle(idx, x, y, z + 2.0, a + 90.0, -1, -1, 90);
    vspawn[playerid] = false;
    SetTimerEx("ToggleSpawn", 60000, false,"e",playerid);
    LinkVehicleToInterior(curPlayerVehI[playerid], GetPlayerInterior(playerid));


    curServerVehP[curPlayerVehI[playerid]][spawn] = true;
    curServerVehP[curPlayerVehI[playerid]][vmodel] = idx;
    curServerVehP[curPlayerVehI[playerid]][vInt] = GetPlayerInterior(playerid);
    SetVehicleNumberPlate(GetPlayerInterior(playerid), String);
    SetVehicleToRespawn(GetPlayerInterior(playerid));
    PutPlayerInVehicle(playerid, GetPlayerInterior(playerid), 0);


    format(iString, 128, "[SUCCESS]: You spawned \"%s\" (ID: %d, VEHICLE ID: %d)", aVehicleNames[idx - MIN_VEHI_ID], idx, curPlayerVehI[playerid]);


    SendClientMessage(playerid, COLOR_GREEN, iString);
    }
    return true;
    }
    strtok(const string[], &index)
    { // Created by Compuphase


    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
    index++;
    }


    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
    result[index - offset] = string[index];
    index++;
    }
    result[index - offset] = EOS;
    return result;
    }



    GetVehicleModelIDFromName(vname[])
    {
    for(new i = 0; i < 211; i++) {
    if (strfind(aVehicleNames[i], vname, true) != -1) {
    return i + MIN_VEHI_ID;
    }
    }
    return -1;
    }


    public ToggleSpawn(playerid) {
    vspawn[playerid] = true;
    }


    Könnt ihe mir helfen?

  • SetTimerEx("ToggleSpawn", 60000, false,"i",playerid); //Da darf kein "e" stehen, sondern ein "i"
    idx = GetVehicleModelIDFromName(params); //Ich kenne mich mit dcmd nicht aus, aber ich denke hier müsste statt params[1] params stehen.


    Ansonsten ist mir kein Fehler aufgefalen