Jaa ich habe hier ein Filterscript. =)
Damit kann ich in ein beliebiges Auto einsteigen und /autokaufen eingeben. Die Funktion erklärt sich wohl selbst =)
Dann kann man das Auto Verkaufen mit /autoverkaufen und das gekaufte Auto von Überall vor sich Spawnen lassen mit /auto.
hat man ein Auto gekauft und loggt sich neu ein, kann man das auto immernoch normal mit /Auto abrufen.
Dies geht allerdings nicht, wenn ich den Server restarte. Dann sagt mir das Script, dass ich kein Auto gekauft habe.
Um das Problem zu lösen/ im Script ein solches Speicher/ lademodul einzubauen, bräuchte ich bitte hilfe =)
#include <a_samp>
#define COLOR_GREEN 0x33AA33AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
#define COLOR_WHITE 0xFFFFFFAA
#define CAR_COST 50000
new owner[MAX_VEHICLES];
new ownedcar[MAX_PLAYERS];
new lockedCar[MAX_VEHICLES];
new wasInVehicle[MAX_PLAYERS];
//-------------------------//
public OnFilterScriptInit()
{
print(" //-------------------------------\\ ");
print(" \\-------------------------------// ");
print(" Auto System geladen! ");
print(" //-------------------------------\\ ");
print(" \\-------------------------------// ");
for (new i=0;i<MAX_PLAYERS;i++)
{
ownedcar[i]=-1;
wasInVehicle[i]=-1;
}
for (new i=0;i<MAX_VEHICLES;i++)
{
owner[i]=-1;
lockedCar[i]=0;
}
}
//-------------------------//
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid,COLOR_RED,"wenn du eine Uebersicht der Befehle brauchst, gib /autohilfe ein.");
for (new i=0;i<700;i++)
{
if (lockedCar[i]==1)
{
SetVehicleParamsForPlayer( i, playerid, 0, 1);
}
}
}
//-------------------------//
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new cmd[255];
new tmp[255];
cmd = strtok(cmdtext,idx);
if (strcmp(cmdtext, "/autohilfe", true)==0)
{
SendClientMessage(playerid, COLOR_YELLOW,"/zu, /auf, /autokaufen, /autoverkaufen, /auto, /aussteigen, /alleaussteigen");
return 1;
}
if (strcmp(cmdtext, "/zu", true)==0)
{
if (IsPlayerInAnyVehicle(playerid))
{
new State=GetPlayerState(playerid);
if (State!=PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,0xFFFF00AA,"Du kannst das Auto nur als Besitzer aufschliessen.");
return 1;
}
lockedCar[GetPlayerVehicleID(playerid)]=1;
new i;
for (i=0;i<MAX_PLAYERS;i++)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
}
}
SendClientMessage(playerid, 0xFFFF00AA, "Auto abgeschlossen!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1056,pX,pY,pZ);
}
else
{
SendClientMessage(playerid, 0xFFFF00AA, "Du bist in keinem Auto!");
}
return 1;
}
if (strcmp(cmdtext, "/auf", true)==0)
{
if (IsPlayerInAnyVehicle(playerid))
{
new State=GetPlayerState(playerid);
if (State!=PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,0xFFFF00AA,"Du kannst das Auto nur als Besitzer aufschliessen.");
return 1;
}
new i;
lockedCar[GetPlayerVehicleID(playerid)]=0;
for (i=0;i<MAX_PLAYERS;i++)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
}
SendClientMessage(playerid, 0xFFFF00AA, "Auto aufgeschlossen!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1057,pX,pY,pZ);
}
else
{
SendClientMessage(playerid, 0xFFFF00AA, "Du bist in keinem Auto!");
}
return 1;
}
if (strcmp(cmdtext, "/autokaufen", true)==0)
{
if (GetPlayerMoney(playerid) < CAR_COST)
{
SendClientMessage(playerid,COLOR_YELLOW,"Du hast keine 150000$ um das Auto zu kaufen.");
return 1;
}
if (!(IsPlayerInAnyVehicle(playerid)))
{
SendClientMessage(playerid,COLOR_YELLOW,"Steig in ein Auto, um es zu kaufen.");
return 1;
}
if (owner[GetPlayerVehicleID(playerid)]!=-1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Dieses Auto hat bereits einen Inhaber.");
return 1;
}
if (ownedcar[playerid]!=-1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Du hast bereits ein Auto, nutze vorher /autoverkaufen.");
return 1;
}
ownedcar[playerid] = GetPlayerVehicleID(playerid);
owner[ownedcar[playerid]] = playerid;
SendClientMessage(playerid,COLOR_YELLOW,"Auto gekauft!");
GivePlayerMoney(playerid,-CAR_COST);
return 1;
}
if (strcmp(cmdtext, "/autoverkaufen", true)==0)
{
if (ownedcar[playerid]==-1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Du hast kein Auto.");
return 1;
}
if (lockedCar[ownedcar[playerid]]==1)
{
lockedCar[ownedcar[playerid]]=0;
for (new i=0;i<MAX_PLAYERS;i++)
{
SetVehicleParamsForPlayer(ownedcar[playerid],i, 0, 0);
}
}
owner[ownedcar[playerid]] = -1;
ownedcar[playerid] = -1;
SendClientMessage(playerid,COLOR_YELLOW,"Du hast dein Auto verkauft und bekommst die Haelte des Kaufpreises erstattet.");
GivePlayerMoney(playerid,CAR_COST/2);
return 1;
}
if (strcmp(cmdtext, "/auto", true)==0)
{
if (ownedcar[playerid] != -1)
{
if (GetPlayerMoney(playerid) < 1000)
{
SendClientMessage(playerid,COLOR_YELLOW,"Du hast zu wenig Geld, um den Mechaniker zu bezahlen.");
}
else
{
new Float:playerpos[4];
GetPlayerPos(playerid,playerpos[0],playerpos[1],playerpos[2]);
GetPlayerFacingAngle(playerid,playerpos[3]);
SetVehicleZAngle(ownedcar[playerid],playerpos[3]+90.0);
SetVehiclePos(ownedcar[playerid],playerpos[0]+3.0*floatsin(-playerpos[3],degrees),playerpos[1]+3.0*floatcos(-playerpos[3],degrees),playerpos[2]+0.5); // This one is cool that I am using trigo functions to set the vehicle just before you.
SendClientMessage(playerid,COLOR_YELLOW,"Der Mechaniker hat dir dein Auto gebracht.");
GivePlayerMoney(playerid,-1000);
}
}
}
if (strcmp(cmd,"/aussteigen", true)==0){
new vehicleid;
new pid;
new playerstate = GetPlayerState(playerid);
tmp = strtok(cmdtext,idx);
if (!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,COLOR_YELLOW,"Du bist in keinem Auto!");
return 1;
}
if (playerstate == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"Beifahrer koennen dies nicht tuhen!");
return 1;
}
vehicleid = GetPlayerVehicleID(playerid);
if (!strlen(tmp))
{
SendClientMessage(playerid,COLOR_WHITE,"NUTZE: /aussteigen [playerid]");
return 1;
}
pid = strval(tmp);
if (!IsPlayerConnected(pid))
{
SendClientMessage(playerid,COLOR_RED,"Spieler nicht online.");
return 1;
}
if (!IsPlayerInVehicle(pid,vehicleid))
{
SendClientMessage(playerid,COLOR_RED,"Dieser Spieler ist nicht in deinem Auto.");
return 1;
}
else
{
RemovePlayerFromVehicle(pid);
GameTextForPlayer(pid,"~r~DU WURDEST RAUSGEWORFEN!",3000,5);
return 1;
}
}
if (strcmp(cmd,"/alleaussteigen", true)==0){
new vehicleid;
new playerstate = GetPlayerState(playerid);
if (!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,COLOR_YELLOW,"Du bist in keinem Auto");
return 1;
}
if (playerstate == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"Beifahrer koennen dies nicht nutzen!");
return 1;
}
vehicleid = GetPlayerVehicleID(playerid);
for (new i=0;i<MAX_PLAYERS;i++)
{
if ((IsPlayerConnected(i))&&(IsPlayerInVehicle(i,vehicleid)))
{
RemovePlayerFromVehicle(i);
GameTextForPlayer(i,"~r~DU WURDEST RAUSGEWORFEN!",3000,5);
return 1;
}
}
}
return 0;
}
//------------------------------------------------------------------------------
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate==PLAYER_STATE_DRIVER)
{
wasInVehicle[playerid]=GetPlayerVehicleID(playerid);
if ((owner[GetPlayerVehicleID(playerid)]!=-1)&&(owner[GetPlayerVehicleID(playerid)]!=playerid))
{
new name[MAX_PLAYER_NAME];
new msg[256];
GetPlayerName(owner[GetPlayerVehicleID(playerid)],name,sizeof(name));
format(msg,sizeof(msg),"Dieses Auto gehoert: %s",name);
}
}
if (newstate==PLAYER_STATE_PASSENGER)
{
if ((owner[GetPlayerVehicleID(playerid)]!=-1)&&(owner[GetPlayerVehicleID(playerid)]!=playerid))
{
new name[MAX_PLAYER_NAME];
new msg[256];
GetPlayerName(owner[GetPlayerVehicleID(playerid)],name,sizeof(name));
format(msg,sizeof(msg),"Dieses Auto gehoert: %s",name);
SendClientMessage(playerid,COLOR_YELLOW,msg);
}
}
if (newstate==PLAYER_STATE_ONFOOT)
{
if ((wasInVehicle[playerid]!=ownedcar[playerid])&&(lockedCar[wasInVehicle[playerid]]==1))
{
lockedCar[GetPlayerVehicleID(playerid)]=0;
for (new i=0;i<MAX_PLAYERS;i++)
{
SetVehicleParamsForPlayer(ownedcar[playerid],i, 0, 0);
}
SendClientMessage(playerid, 0xFFFF00AA, "Aufgeschlossen!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1057,pX,pY,pZ);
}
}
return 1;
}
//------------------------------------------------------------------------------
public OnPlayerDisconnect(playerid, reason)
{
if ((ownedcar[playerid]!=-1)&&(lockedCar[ownedcar[playerid]]=1))
{
lockedCar[ownedcar[playerid]]=0;
for (new i=0;i<MAX_PLAYERS;i++)
{
SetVehicleParamsForPlayer(ownedcar[playerid],i, 0, 0);
}
}
if (ownedcar[playerid]!=-1)
{
owner[ownedcar[playerid]]=-1;
ownedcar[playerid]=-1;
}
wasInVehicle[playerid]=-1;
return 1;
}
//------------------------------------------------------------------------------
strtok(const string[], &index)
{
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;
}
//------------------------------------------------------------------------------
Alles anzeigen