[Tutorial] Mod Shop Bug Fix
#1

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.
Reply
#2

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.
Reply
#3

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..?
Reply
#4

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?
Reply
#5

very thanks, i will test soon it.. )
Reply
#6

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.
Reply
#7

Bob needs this...
Reply
#8

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

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

-snip, it's 3am here-
Reply
#11

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.
Reply
#12

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
Reply
#13

Not worked for me:S
Reply
#14

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.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)