Hey Leute,
Ich habe mir ein Filterscript gedownloadet und habe dieses direkt in mein Gamemode übertragen, jedoch gibt es ein Problem jeder kann in das gemietete Fahrzeug einsteigen auch wenn diese Person kein Admin ist eigentlich ist der Sinn ja das man da nur einsteigen kann wenn man den Wagen auch gemietet hat.
Hier mal der Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==PLAYER_STATE_DRIVER)
{
for(new i=0; i<MAX_CARS; i++)
{
if(GetPlayerVehicleID(playerid)==MCInfo[i][mietcar])
{
if(!IsPlayerAnAdministrator(playerid) && !IsPlayerAdmin(playerid) && Key[playerid] != MCInfo[i][mcmietkey] && MCInfo[i][mcBenutzt] == 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,ROT,"Du darfst dieses Fahrzeug nicht fahren.");
}
}
}
}
return 1;
}
und hier das Ganße Filterscript :
#include <dini>
#include <sscanf>
#define BLAU 0x0087FFFF
#define ROT 0xE10000FF
/*
Die Credits gehen an Myname1997
Währe nett wenn es drinne bleibt :P
*/
/*
Im Gamemode muss eingetragen werden:
public MCar_IsPlayerAnAdmin(playerid)
{
if(PlayerInfo[playerid][pAdmin] != 0) return PlayerInfo[playerid][pAdmin]; //hier müsst ihr anstatt pAdmin eure Admin-abfrage rein machen
return 1;
}
*/
{
mietcar,
modelid,
Float:mcx,
Float:mcy,
Float:mcz,
Float:mca,
mcc1,
mcc2,
cpreis,
mcmietkey,
mcBenutzt,
Text3D:mclabel,
mcopen
}
new MCInfo[MAX_CARS][mietcarinfo];
"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 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", "Boxvillde", "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 LA", "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 Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway",
"Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer 3", "Emperor", "Wayfarer", "Euros", "Hotdog",
"Club", "Freight Carriage", "Trailer 4", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)", "Police Car (SFPD)",
"Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer A",
"Luggage Trailer B", "Stairs", "Boxville", "Tiller", "Utility Trailer" };
{
print("\n--------------------------------------");
print("Mietsystem\n");
print("By Myname1997\n");
print("--------------------------------------\n");
for(new i=0;i<MAX_CARS;i++)
{
LMC(i);
}
return 1;
}
{
for(new i=0;i<MAX_CARS;i++)
{
SMC(i);
}
return 1;
}
{
for(new i=0;i<MAX_CARS;i++)
{
if(vehicleid == MCInfo[i][mietcar])
{
if(MCInfo[i][mcopen] == 0)
{
SendClientMessage(playerid,ROT,"[Mietcar-System-ERROR:] Das Fahrzeug ist Abgeschloßen!");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z+1);
}
}
}
return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
new cmd[256];
new tmp[256];
new idx;
cmd = strtok(cmdtext, idx);
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,ROT,"[Mietcar-System-ERROR:] Sie sind in keinem Auto!");
new veh;
veh = GetPlayerVehicleID(playerid);
for(new i=0;i<MAX_CARS;i++)
{
if(veh == MCInfo[i][mietcar])
{
if(IsPlayerAnAdministrator(playerid) < NEEDEDADMLVL && !IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,ROT,"[Mietcar-System-ERROR:] Sie sind nicht berechtigt dieses Fahrzeug zu parken!");
return 1;
}
new Float:x,Float:y,Float:z,Float:a;
GetVehiclePos(veh,x,y,z);
GetVehicleZAngle(veh,a);
MCInfo[i][mcx] = x;
MCInfo[i][mcy] = y;
MCInfo[i][mcz] = z;
MCInfo[i][mca] = a;
SMC(i);
SendClientMessage(playerid,BLAU,"[Mietcar-System-MELDUNG:] Fahrzeug geparkt!");
}
}
}
return 1;
}
if(strcmp(cmdtext,"/mietcard",true)==0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,ROT,"[ERROR:] Sie sind in keinem Auto!");
new veh;
veh = GetPlayerVehicleID(playerid);
for(new i=0;i<MAX_CARS;i++)
{
if(veh == MCInfo[i][mietcar])
{
if(IsPlayerAnAdministrator(playerid) < NEEDEDADMLVL && !IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,ROT,"[Mietcar-System-ERROR:] Sie sind nicht berechtigt dieses Fahrzeug zu parken!");
return 1;
}
Delete3DTextLabel(MCInfo[i][mclabel]);
DestroyVehicle(MCInfo[i][mietcar]);
new SDatei[64];
format(SDatei,50,"/mietcar/%d.txt",i);
dini_Remove(SDatei);
SendClientMessage(playerid,BLAU,"[Mietcar-System-MELDUNG:] Fahrzeug gelöscht!");
}
}
}
return 1;
}
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerAnAdministrator(playerid) < NEEDEDADMLVL && !IsPlayerAdmin(playerid)) return 1;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ROT, "Benutze: /mietnew [model] [farbe1] [farbe2] [mietpreis]");
return 1;
}
new model;
model = strval(tmp);
if(model < 400 || model > 611) return SendClientMessage(playerid,ROT,"[Mietcar-System-ERROR:] Die Modelid darf nicht über 611 bzw. unter 400 liegen!");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ROT, "Benutze: /mietnew [model] [farbe1] [farbe2] [mietpreis]");
return 1;
}
new farbe1;
farbe1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ROT, "Benutze: /mietnew [model] [farbe1] [farbe2] [mietpreis]");
return 1;
}
new farbe2;
farbe2 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ROT, "Benutze: /mietnew [model] [farbe1] [farbe2] [mietpreis]");
return 1;
}
new mietpreis;
mietpreis = strval(tmp);
tmp = strtok(cmdtext,idx);
if(strlen(tmp))
{
SendClientMessage(playerid, ROT, "Benutze: /mietnew [model] [farbe1] [farbe2] [mietpreis]");
return 1;
}
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
new mietkey2 = random(MAX_CARS)+5000;
CMC(model,x,y,z,a,farbe1,farbe2,mietpreis,mietkey2);
new string[256];
format(string,sizeof(string),"[Mietcar-System-MELDUNG:] Ein(e) %s wurde an den Koordinaten '%f,%f,%f' zu $%d erstellt!",PlayerVehicle[model-400],x,y,z,mietpreis);
SendClientMessage(playerid,BLAU,string);
GameTextForPlayer(playerid,"Mietcar wurde erstellt~n~Vergessen sie es nicht mit~n~~r~/mietcarp~w~ zu Parken!",5000,6);
}
return 1;
}
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,ROT,"[Mietcar-System-ERROR:] Sie sind in keinem Auto!");
new veh;
veh = GetPlayerVehicleID(playerid);
for(new i=0;i<MAX_CARS;i++)
{
if(veh == MCInfo[i][mietcar])
{
if(MCInfo[i][mcBenutzt] == 1) return SendClientMessage(playerid,ROT,"Dieses Fahrzeug wurde bereits gemietet!");
if(Key[playerid] != 0) return SendClientMessage(playerid,ROT,"Sie haben bereits ein car gemietet '/unrentmcar' zum Entmieten!");
if(GetPlayerMoney(playerid) < MCInfo[i][cpreis]) return SendClientMessage(playerid,ROT,"Sie haben nicht genug Geld dabei!");
Key[playerid] = MCInfo[i][mcmietkey];
MCInfo[i][mcBenutzt] = 1;
GivePlayerMoney(playerid,-MCInfo[i][cpreis]);
GameTextForPlayer(playerid,"Fahrezug gemietet~n~Viel Spass damit!",5000,0);
Delete3DTextLabel(MCInfo[i][mclabel]);
}
}
}
return 1;
}
if(strcmp(cmdtext,"/rentlock",true)==0)
{
if(IsPlayerConnected(playerid))
{
for(new i=0;i<MAX_CARS;i++)
{
if(Key[playerid] == 0) return SendClientMessage(playerid,ROT,"Sie haben kein car gemietet!");
if(Key[playerid] == MCInfo[i][mcmietkey])
{
if(MCInfo[i][mcopen] == 1)
{
MCInfo[i][mcopen] = 0;
SendClientMessage(playerid,BLAU,"[Mietcar-System-MELDUNG:] Fahrzeug abgeschloßen!");
}
else if(MCInfo[i][mcopen] == 0)
{
MCInfo[i][mcopen] = 1;
SendClientMessage(playerid,BLAU,"[Mietcar-System-MELDUNG:] Fahrzeug aufgeschloßen!");
}
}
}
}
return 1;
}
if(strcmp(cmdtext,"/unrentmcar",true)==0)
{
if(IsPlayerConnected(playerid))
{
for(new i=0;i<MAX_CARS;i++)
{
if(Key[playerid] == 0) return SendClientMessage(playerid,ROT,"Sie haben kein car gemietet!");
if(Key[playerid] == MCInfo[i][mcmietkey])
{
//SetVehicleToRespawn(MCInfo[i][mietcar]);
DestroyVehicle(MCInfo[i][mietcar]);
Key[playerid] = 0;
MCInfo[i][mcBenutzt] = 0;
GameTextForPlayer(playerid,"Fahrezug entmietet~n~!",5000,0);
LMC(i);
}
}
}
return 1;
}
return 1;
}
{
if(newstate==PLAYER_STATE_DRIVER)
{
for(new i=0; i<MAX_CARS; i++)
{
if(GetPlayerVehicleID(playerid)==MCInfo[i][mietcar])
{
if(!IsPlayerAnAdministrator(playerid) && !IsPlayerAdmin(playerid) && Key[playerid] != MCInfo[i][mcmietkey] && MCInfo[i][mcBenutzt] == 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,ROT,"Du darfst dieses Fahrzeug nicht fahren.");
}
}
}
}
return 1;
}
{
new SDatei[64];
for(new carid=1;carid<MAX_CARS;carid++)
{
format(SDatei,50,"/mietcar/%d.txt",carid);
if(!fexist(SDatei))
{
dini_Create(SDatei);
dini_IntSet(SDatei,"Model",model);
dini_FloatSet(SDatei,"X",fx);
dini_FloatSet(SDatei,"Y",fy);
dini_FloatSet(SDatei,"Z",fz);
dini_FloatSet(SDatei,"A",fa);
dini_IntSet(SDatei,"Farbe1",farbe1);
dini_IntSet(SDatei,"Farbe2",farbe2);
dini_IntSet(SDatei,"Preis",mietpreis);
dini_IntSet(SDatei,"mietkey",mietkey2);
MCInfo[carid][mietcar] = CreateVehicle(model,fx,fy,fz,fa,farbe1,farbe2,-1);
format(labelstring,sizeof(labelstring),"Fahrzeugname:%s\nPreis:$%d",PlayerVehicle[model-400],mietpreis);
MCInfo[carid][mclabel] = Create3DTextLabel(labelstring, 0xFFFFFFFF, 0.0,0.0,0.0,9.0,0);
Attach3DTextLabelToVehicle(MCInfo[carid][mclabel],MCInfo[carid][mietcar],0,0,0);
MCInfo[carid][modelid] = dini_Int(SDatei,"Model");
MCInfo[carid][mcx] = dini_Float(SDatei,"X");
MCInfo[carid][mcy] = dini_Float(SDatei,"Y");
MCInfo[carid][mcz] = dini_Float(SDatei,"Z");
MCInfo[carid][mca] = dini_Float(SDatei,"A");
MCInfo[carid][cpreis] = dini_Int(SDatei,"Preis");
MCInfo[carid][mcc1] = dini_Int(SDatei,"Farbe1");
MCInfo[carid][mcc2] = dini_Int(SDatei,"Farbe2");
MCInfo[carid][mcmietkey] = dini_Int(SDatei,"mietkey");
MCInfo[carid][mcBenutzt] = 0;
MCInfo[carid][mcopen] = 1;
return 1;
}
}
return 1;
}
{
new SDatei[64];
format(SDatei,50,"/mietcar/%d.txt",carid);
//if(!fexist(SDatei)) return 0;
dini_IntSet(SDatei,"Model",MCInfo[carid][modelid]);
dini_FloatSet(SDatei,"X",MCInfo[carid][mcx]);
dini_FloatSet(SDatei,"Y",MCInfo[carid][mcy]);
dini_FloatSet(SDatei,"Z",MCInfo[carid][mcz]);
dini_FloatSet(SDatei,"A",MCInfo[carid][mca]);
dini_IntSet(SDatei,"Farbe1",MCInfo[carid][mcc1]);
dini_IntSet(SDatei,"Farbe2",MCInfo[carid][mcc2]);
dini_IntSet(SDatei,"Preis",MCInfo[carid][cpreis]);
dini_IntSet(SDatei,"mietkey",MCInfo[carid][mcmietkey]);
return 1;
}
{
new SDatei[64];
format(SDatei,50,"/mietcar/%d.txt",carid);
if(!fexist(SDatei)) return 0;
MCInfo[carid][modelid] = dini_Int(SDatei,"Model");
MCInfo[carid][mcx] = dini_Float(SDatei,"X");
MCInfo[carid][mcy] = dini_Float(SDatei,"Y");
MCInfo[carid][mcz] = dini_Float(SDatei,"Z");
MCInfo[carid][mca] = dini_Float(SDatei,"A");
MCInfo[carid][cpreis] = dini_Int(SDatei,"Preis");
MCInfo[carid][mcc1] = dini_Int(SDatei,"Farbe1");
MCInfo[carid][mcc2] = dini_Int(SDatei,"Farbe2");
MCInfo[carid][mcmietkey] = dini_Int(SDatei,"mietkey");
MCInfo[carid][mietcar] = CreateVehicle(MCInfo[carid][modelid],MCInfo[carid][mcx],MCInfo[carid][mcy],MCInfo[carid][mcz],MCInfo[carid][mca],MCInfo[carid][mcc1],MCInfo[carid][mcc2],-1);
MCInfo[carid][mcopen] = 1;
new labelstring[256];
format(labelstring,sizeof(labelstring),"Fahrzeugname:%s\nPreis:$%d",PlayerVehicle[MCInfo[carid][modelid]-400],MCInfo[carid][cpreis]);
MCInfo[carid][mclabel] = Create3DTextLabel(labelstring, 0xFFFFFFFF, 0.0,0.0,0.0,9.0,0);
Attach3DTextLabelToVehicle(MCInfo[carid][mclabel],MCInfo[carid][mietcar],0,0,0);
return 1;
}
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
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;
}
{
return CallLocalFunction("MCar_IsPlayerAnAdmin","i",playerid);
}