SA-MP Forums Archive
[Tutorial] Mod Shop Bug Fix - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Mod Shop Bug Fix (/showthread.php?tid=172757)



Mod Shop Bug Fix - DiddyBop - 31.08.2010

For some people, There mod shop is bugged, you go in, then someone else goes in behind you, And then your both crashing into eachother in the mod shop.

Well here is how i fixed the bug for my server (Not sure if it happens to everyone, but i thought i'd share).


First, The callback.

Search in your GameMode/Filterscript for
pawn Code:
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
       return 1;
}
Next, directly under the first curly bracket
pawn Code:
{
Add this code.

pawn Code:
new vehid;
    vehid = GetPlayerVehicleID(playerid);
    SetPlayerVirtualWorld(playerid, random(555)+random(999));
    SetVehicleVirtualWorld(vehid, GetPlayerVirtualWorld(playerid));
    PutPlayerInVehicle(playerid, vehid, 0);
   
    if(enterexit == 0)
    {
        SetVehicleVirtualWorld(vehid, 0);
        SetPlayerVirtualWorld(playerid, 0);
        PutPlayerInVehicle(playerid, vehid, 0);
    }
So at end, it will look like..

pawn Code:
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
    new vehid;
    vehid = GetPlayerVehicleID(playerid);
    SetPlayerVirtualWorld(playerid, random(555)+random(999));
    SetVehicleVirtualWorld(vehid, GetPlayerVirtualWorld(playerid));
    PutPlayerInVehicle(playerid, vehid, 0);
   
    if(enterexit == 0)
    {
        SetVehicleVirtualWorld(vehid, 0);
        SetPlayerVirtualWorld(playerid, 0);
        PutPlayerInVehicle(playerid, vehid, 0);
    }
    return 1;
}

Now let me explain what everything does.

The callback.
pawn Code:
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
       //This is where your code/script/data gets processed/executed ingame.
       return 1;
}
The variable
pawn Code:
new vehid; //Setting the variable for the players car to save to
The virtual worlds.
pawn Code:
SetPlayerVirtualWorld(playerid, random(555)+random(999)); //Sets the players virtual world
    SetVehicleVirtualWorld(vehid, GetPlayerVirtualWorld(playerid)); //Puts his car, in his virtual world
PutPlayerInVehicle(playerid, CARID, seat);
pawn Code:
PutPlayerInVehicle(playerid, vehid, 0); //Puts the player in vehicle.
For more information on PutPlayerInVehicle, Click this line.

The "if" Statement.
pawn Code:
if(enterexit == 0)
    {
//This checks it the player has EXITED, the mod garage (1 for enter)
//And then script/code gets put in here.
     }
And there you go. Very simple tut to a very annoying bug i kept running into.


Re: Mod Shop Bug Fix - Vince - 31.08.2010

Very useful, but I think this will be much cleaner:

pawn Code:
SetPlayerVirtualWorld(playerid, playerid); //Sets the players virtual world
As there won't be 2 same playerids connected at the same time.


Re: Mod Shop Bug Fix - DiddyBop - 31.08.2010

Quote:
Originally Posted by Vince
View Post
Very useful, but I think this will be much cleaner:

pawn Code:
SetPlayerVirtualWorld(playerid, playerid); //Sets the players virtual world
As there won't be 2 same playerids connected at the same time.
it will put them in the virtual world they are already in..?


AW: Mod Shop Bug Fix - FufLa - 31.08.2010

You should also have a look at passengers. AFAIK (not sure tho) the callback doesnt get called for passengers (never tested)? You still got to set their virtual world too, or they end up in a mod shop without a vehicle?


Re: Mod Shop Bug Fix - AndriusZ* - 31.08.2010

very thanks, i will test soon it.. )


Re: Mod Shop Bug Fix - DiddyBop - 01.09.2010

Quote:
Originally Posted by Y_Less
View Post
No it won't, he is correct in that that method will put every player in a unique world whereas your method may not. Player 0 will go in world 0, player 1 will go in world 1 etc. With yours players 0 and 1 may both get world 0 - that is a valid outcome for 4 random calls.
oh i see, didnt understand at first.

Putting them in there playerid's world.


Re: Mod Shop Bug Fix - willsuckformoney - 05.09.2010

Bob needs this...


Re: Mod Shop Bug Fix - DiddyBop - 06.09.2010

Quote:
Originally Posted by willsuckformoney
View Post
Bob needs this...
bobs has it.. i never ran into anyone on there o.O


Re: Mod Shop Bug Fix - willsuckformoney - 06.09.2010

Oh really? How come almost every time i enter the trans with someone in it they fly to blueberry D:


Re: Mod Shop Bug Fix - General Abe - 03.10.2010

-snip, it's 3am here-


Re: Mod Shop Bug Fix - ••• ĤБĶБM ••• - 25.10.2010

The passengers will be bugged if they exit the vehicle while the driver is tuning the vehicle. Either make one for that, or I'll consider it as a "FAIL" for me, since there's no point of only driver, to be honest.


Re: Mod Shop Bug Fix - DiddyBop - 14.11.2010

Quote:
Originally Posted by ••• ĤБĶБM •••
View Post
The passengers will be bugged if they exit the vehicle while the driver is tuning the vehicle. Either make one for that, or I'll consider it as a "FAIL" for me, since there's no point of only driver, to be honest.
could care less what you consider as a fail tbh


Re: Mod Shop Bug Fix - Mariooo - 29.12.2010

Not worked for me:S


Re: Mod Shop Bug Fix - Fool - 29.12.2010

Quote:
Originally Posted by Mariooo
View Post
Not worked for me:S
well, instead of getting counfused you can tell us your errors/warnings. that would be great.