Author Topic: Modshop Fix - No collisions  (Read 2088 times)

0 Members and 1 Guest are viewing this topic.

Offline Fuse

  • SA-MP Donator
  • *
  • Posts: 1048
    • Awards
Modshop Fix - No collisions
« on: June 18, 2014, 08:00:26 PM »
Code: [Select]
#include <a_samp>

#if defined MAX_PLAYERS
#undef MAX_PLAYERS
#endif
#define MAX_PLAYERS 32

new playerPrevWorld[MAX_PLAYERS],
maxPlayers;

public OnFilterScriptInit()
maxPlayers = GetMaxPlayers();

public OnEnterExitModShop(playerid, enterexit, interiorid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid)
{
if(enterexit) // Enter
{
playerPrevWorld[playerid] = GetPlayerVirtualWorld(playerid);
SetVehicleVirtualWorld(vehicleid, playerid);
for(new veh_playerid = 0; veh_playerid < maxPlayers; veh_playerid ++)
{
if(IsPlayerConnected(veh_playerid) && GetPlayerVehicleID(veh_playerid) == vehicleid)
SetPlayerVirtualWorld(veh_playerid, playerid);
}
}
else // Exit
{
SetVehicleVirtualWorld(vehicleid, playerPrevWorld[playerid]);
for(new veh_playerid = 0; veh_playerid < maxPlayers; veh_playerid ++)
{
if(IsPlayerConnected(veh_playerid) && GetPlayerVehicleID(veh_playerid) == vehicleid)
SetPlayerVirtualWorld(veh_playerid, playerPrevWorld[playerid]);
}
}
}
}
With this cars don't collide with eachothers inside the modshops because all vehicles inside the shops are set to empty virtual worlds.
I just made it and i hope you add it to the server  :)
« Last Edit: June 19, 2014, 01:46:31 PM by Fuse »

Offline [V]Playa

  • SA-MP Server Admin
  • *
  • *
  • *
  • Posts: 1581
    • Awards
  • SA-MP: [V]Playa
Re: Modshop Fix - No collisions & passengers can enter
« Reply #1 on: June 18, 2014, 08:48:00 PM »
Code: [Select]
#include <a_samp>

#if defined MAX_PLAYERS
#undef MAX_PLAYERS
#endif
#define MAX_PLAYERS 32

new playerPrevWorld[MAX_PLAYERS],
    maxPlayers;

public OnFilterScriptInit()
    maxPlayers = GetMaxPlayers();

public OnEnterExitModShop(playerid, enterexit, interiorid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(vehicleid)
    {
        if(enterexit) // Enter
        {
            for(new worldid = 0; worldid < maxPlayers; worldid ++)
            {
                new world_players;
                for(new world_playerid = 0; world_playerid < maxPlayers; world_playerid ++)
                {
                    if(IsPlayerConnected(world_playerid) && playerid != world_playerid && GetPlayerVirtualWorld(world_playerid) == worldid)
                        world_players ++;
                }
                if(!world_players)
                {
                    playerPrevWorld[playerid] = GetPlayerVirtualWorld(playerid);
                    SetVehicleVirtualWorld(vehicleid, worldid);
                    LinkVehicleToInterior(vehicleid, interiorid);
                    for(new veh_playerid = 0; veh_playerid < maxPlayers; veh_playerid ++)
                    {
                        if(IsPlayerConnected(veh_playerid) && GetPlayerVehicleID(veh_playerid) == vehicleid)
                        {
                            SetPlayerVirtualWorld(veh_playerid, worldid);
                            SetPlayerInterior(veh_playerid, interiorid);
                        }
                    }
                    break;
                }
            }
        }
        else // Exit
        {
            SetVehicleVirtualWorld(vehicleid, playerPrevWorld[playerid]);
            LinkVehicleToInterior(vehicleid, 0);
            for(new veh_playerid = 0; veh_playerid < maxPlayers; veh_playerid ++)
            {
                if(IsPlayerConnected(veh_playerid) && GetPlayerVehicleID(veh_playerid) == vehicleid)
                {
                    SetPlayerVirtualWorld(veh_playerid, playerPrevWorld[playerid]);
                    SetPlayerInterior(veh_playerid, 0);
                }
            }
        }
    }
}
With this you can enter modshops as passenger, also cars don't collide with eachothers inside the modshops because all vehicles inside the shops are set to empty virtual worlds.
I just made it and i hope you add it to the server  :)
It is really a good idea (cuz i hate the car get damaged, and cant see the parts i did :o) if i can gove my vote (+1)
« Last Edit: June 18, 2014, 10:09:08 PM by [B]PlaYa »

Offline Runey

  • SA-MP Server Admin
  • *
  • *
  • Posts: 2265
    • Awards
Re: Modshop Fix - No collisions
« Reply #2 on: June 18, 2014, 09:16:20 PM »
Im the first who tested it,works really nice though.Good work fuse! ;)

Offline EnzoMortelli

Re: Modshop Fix - No collisions
« Reply #3 on: June 18, 2014, 09:21:03 PM »
@Playa: colliding cars inside modshops do not take damage.

Apart from that good work Fuse. I like it.
It's annoying if someone pushes your car aside and you don't see how the added parts look.
« Last Edit: June 18, 2014, 09:22:37 PM by EnzoMortelli »

Offline Quickplay

  • SA-MP Retirees
  • *
  • *
  • Posts: 2212
  • Crazy Mind
    • Awards
  • SA-MP: Quickplay
Re: Modshop Fix - No collisions
« Reply #4 on: June 18, 2014, 09:30:48 PM »
nice one!

Offline BikeDriver

  • Fisher
  • ******
  • Posts: 1765
  • I can do anything
    • Awards
Re: Modshop Fix - No collisions
« Reply #5 on: June 18, 2014, 10:38:01 PM »
I'm not into pawn but wouldn't it be far easier to just put the player into the virtual world with the same ID as his player ID once he enters the modshop?
BikeDriv:))))

Haha blwelrwelrt, I registered here earlier :P

Offline Fuse

  • SA-MP Donator
  • *
  • Posts: 1048
    • Awards
Re: Modshop Fix - No collisions
« Reply #6 on: June 18, 2014, 10:48:38 PM »
I'm not into pawn but wouldn't it be far easier to just put the player into the virtual world with the same ID as his player ID once he enters the modshop?
It would, i made it this way just to be 100% sure that you enter an empty shop

Offline BikeDriver

  • Fisher
  • ******
  • Posts: 1765
  • I can do anything
    • Awards
Re: Modshop Fix - No collisions
« Reply #7 on: June 19, 2014, 01:14:10 AM »
I don't get it. What is more unique than the player ID?
BikeDriv:))))

Haha blwelrwelrt, I registered here earlier :P

Offline Runey

  • SA-MP Server Admin
  • *
  • *
  • Posts: 2265
    • Awards
Re: Modshop Fix - No collisions
« Reply #8 on: June 19, 2014, 09:14:11 AM »
Probably that.Fuse knows the best,so better listen to him. :)

Offline Fuse

  • SA-MP Donator
  • *
  • Posts: 1048
    • Awards
Re: Modshop Fix - No collisions
« Reply #9 on: June 19, 2014, 11:41:11 AM »
Actually i think i overthinked it, both ways should work just as good :)
Edited the first post
« Last Edit: June 19, 2014, 01:47:22 PM by Fuse »

Offline cripller

  • Tiny Fish
  • *
  • Posts: 17
    • Awards
Re: Modshop Fix - No collisions
« Reply #10 on: June 19, 2014, 01:49:09 PM »
Now this is something interesting! :) Good work! n1 mate!