Die Nummer im Array beim Preis muss die gleiche Nummer sein, wie bei CreateVehicle im Array. Sprich die 1 dort entspricht dem Preis von 1.
Über das i in der Schleife passt das dann automatisch.
[SAMMELTHREAD] Kleine Scripting Fragen
- Rafelder
- Unerledigt
In 10 Minuten startet der nächtliche Backupvorgang! Es kann währenddessen (ca. 10 Minuten) zu Einschränkungen bei der Nutzung des Forums kommen
Weitere Infos findet ihr im Thema Backup des Forums
Dein Problem konnte durch einen User gelöst werden? Bedank dich bei ihm indem du seinen Beitrag als Hilfreich markierst sowie einen Daumen oben dalässt
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
-
-
Code
Alles anzeigenif(newstate == PLAYER_STATE_DRIVER && pInfo[playerid][pAutoschein] ==1) { new vid = GetPlayerVehicleID(playerid); for(new i = 0; i < sizeof(Autohausauto1); i++) { if(vid == Autohausauto1[i]) { ShowPlayerDialog(playerid, DIALOG_AUTOHAUS1, DIALOG_STYLE_LIST, "{FFFFFF}Los Santos exquisit Autohaus", "Auto koscht 1000$", "Kaufen", "Abbrechen"); RemovePlayerFromVehicle(playerid); } } } else { SendClientMessage(playerid,-1,"{c45461}Du brauchst einen •Autoschein um dir ein Fahrzeug zu kaufen."); RemovePlayerFromVehicle(playerid); }
Wenn ich zum Server connecte sagt er mir ich brauch ein Autoschein also das ist dieser Code, warum?
-
else
Zu
else if(newstate == PLAYER_STATE_DRIVER && pInfo[playerid][pAutoschein] != 1)Oder die if-Bedingung teilen, und nur bei der Autoschein Abfrage dann den else Part nehmen.
-
-
Das Array muss so deklariert werden:
new Autohausauto1_name[ANZAHL_HIER][16];
Die 16 steht dabei für die maximale Länge des Namens.Und dann:
format(Autohausauto1_name[ 0 ], 16,"Hotring Racer A");Alternativ kannst du das auch über ein Array aller Fahrzeugnamen dynamisch regeln, über die ModelID. Je nach dem was du auch in den Namen schreiben willst.
-
Code
format(Autohausauto1_name[ 0 ], 16,"Hotring Racer C"); format(Autohausauto1_name[ 0 ], 16,"Hotring Racer B"); format(Autohausauto1_name[ 0 ], 16,"Hotring Racer A");
Wo soll ich das einfügen habe das jetzt unter ongamemodeinit aber der zeigt mir Ingame 0 an, sollte ich das mit einem String verwenden, verstehe das nicht
-
Trage bei den unteren beiden 1 und 2 im Array ein, anstatt 0, sonst wird das erste immer wieder überschrieben.
Die Ausgabe musst du mit %s machen. -
Danke dir!♥
Code
Alles anzeigengetVehicleName(v_model) { new carNames[212][] = {"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","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","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","ZR3 50","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","Cropdust","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 A", "Monster B","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer", "Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor", "Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)", "Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B", "Stair Trailer","Boxville","Farm Plow","Utility Trailer"}; new string[60]; format(string, sizeof(string), "%s", carNames[v_model-400]); return string; }
Habe mir aus einem Totorial eine Fahrzeugliste geholt, aber wie mache ich das dass er mir bei diesem textdraw das Anzeigt weil ich finde wenn man es in einem Timer laufen lässt ist das doch unnötig oder? weil das brauch man ja nur ein mal wenn er einsteigt. Weiß auch nicht wie ich es aufbauen soll. -
aber wie mache ich das dass er mir bei diesem textdraw das Anzeigt
Setze das bei OnPlayerStateChange, wenn newstate == PLAYER_STATE_DRIVER (oder ggf. zusätzlich PLAYER_STATE_PASSENGER).
TextDrawSetString
Und nutze für sowas PlayerTextdraws, andernfalls kommst du schnell an das Limit der möglichen globalen Textdraws.
-
Ja das verstehe ich ja, habe ja schon die Km/h und weiter Texdraws aber wie sieht der Code dazu aus das ist mir gerade komisch
-
-
Die Funktion kannst du komplett löschen, es reicht, wenn du das hier unter die Includes schreibst:
new carNames[212][] = {"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","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","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","ZR3 50","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","Cropdust","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 A",
"Monster B","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer",
"Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor",
"Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)",
"Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
"Stair Trailer","Boxville","Farm Plow","Utility Trailer"};Zugriff so:
new string[32], idx = GetVehicleModel(GetPlayerVehicleID(playerid)) - 400;
format(string, sizeof(string), "Fahrzeug: %s", carNames[idx]);
PlayerTextDrawSetString(/*... ausfüllen ... */); -
Code
(2376) : error 017: undefined symbol "carNames" (2377) : error 012: invalid function call, not a valid address (2377) : warning 215: expression has no effect (2377) : warning 215: expression has no effect (2377) : error 001: expected token: ";", but found ")" (2377) : error 029: invalid expression, assumed zero (2377) : fatal error 107: too many error messages on one line
Codeif(newstate == PLAYER_STATE_DRIVER && pInfo[playerid][pAutoschein] ==1) { new string[32], idx = GetVehicleModel(GetPlayerVehicleID(playerid)) - 400; format(string, sizeof(string), "%s", carNames[idx]); PlayerTextDrawSetString(textdraw_3(playerid, string); }
Wenn ich das auch als Beifahrer haben wie soll ich einfach alles kopieren und PLAYER_STATE_PASSENGER hinschreiben?
-
Hast du das Array mit den Fahrzeugnamen auch unter den Includes eingefügt?
Zwecks dem Beifahrer:
if(newstate == PLAYER_STATE_DRIVER && pInfo[playerid][pAutoschein] ==1)
Zu
if((newstate == PLAYER_STATE_DRIVER && pInfo[playerid][pAutoschein] ==1) || (newstate == PLAYER_STATE_PASSENGER)) -
Unter welchen include? ganz oben da habe ich das irgendwo reingetan
-
Unter der letzten, vor dem ersten public.
Dort wo du auch andere globale Variablen deklariert hast. -
-
textdraw_3
Zu
textdraw_3[playerid]Und ein Komma zwischen playerid und string setzen.
-
Code
if((newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER)) { new string[32], idx = GetVehicleModel(GetPlayerVehicleID(playerid)) - 400; format(string, sizeof(string), "%s", carNames[idx]); PlayerTextDrawSetString(textdraw_3[playerid], string); }
Code
Alles anzeigen(2395) : warning 213: tag mismatch (2395) : error 035: argument type mismatch (argument 2) (2878) : warning 213: tag mismatch (2878) : error 035: argument type mismatch (argument 2) (3895) : warning 203: symbol is never used: "cFahrschule" (3895) : warning 203: symbol is never used: "cLSPD" (3895) : warning 203: symbol is never used: "cStadthalle" (3895) : warning 203: symbol is never used: "fuelName" (3895) : warning 203: symbol is never used: "vehDefaultData" Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase 2 Errors.
-
Den Meldungen nach nutzt du weiterhin kein PlayerTextDraw, dann:
PlayerTextDrawSetString
Zu
TextDrawSetStringWie gesagt sind PlayerTextDraws hierfür eigentlich gedacht.
-
Code
Alles anzeigenif(newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawShow(playerid, textdraw_0[playerid]); if(oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawHide(playerid, textdraw_0[playerid]); if(newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawShow(playerid, textdraw_1[playerid]); if(oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawHide(playerid, textdraw_1[playerid]); if(newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawShow(playerid, textdraw_2[playerid]); if(oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawHide(playerid, textdraw_2[playerid]); if(newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawShow(playerid, textdraw_3[playerid]); if(oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawHide(playerid, textdraw_3[playerid]); if(newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawShow(playerid, textdraw_4[playerid]); if(oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawHide(playerid, textdraw_4[playerid]); if(newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawShow(playerid, textdraw_5[playerid]); if(oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)) PlayerTextDrawHide(playerid, textdraw_5[playerid]);
Hab jetzt erst verstanden was du mir die ganze Zeit mitteilen willst, sorry bin sehr müde.
Habe einen "(" Fehler glaube ich
Code
Alles anzeigen(2384) : error 029: invalid expression, assumed zero (2384) : warning 215: expression has no effect (2384) : error 001: expected token: ";", but found ")" (2384) : error 029: invalid expression, assumed zero (2384) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase 4 Errors.
-