littlewhitey's Servers Forum (SA-MP/VC-MP/MTA/Zomboid)

SA-MP Server - 54.38.156.202:7777 => General => Topic started by: Fuse on June 18, 2014, 08:00:26 PM

Title: Modshop Fix - No collisions
Post by: Fuse 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  :)
Title: Re: Modshop Fix - No collisions & passengers can enter
Post by: [V]Playa 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)
Title: Re: Modshop Fix - No collisions
Post by: Runey on June 18, 2014, 09:16:20 PM
Im the first who tested it,works really nice though.Good work fuse! ;)
Title: Re: Modshop Fix - No collisions
Post by: EnzoMortelli 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.
Title: Re: Modshop Fix - No collisions
Post by: Quickplay on June 18, 2014, 09:30:48 PM
nice one!
Title: Re: Modshop Fix - No collisions
Post by: BikeDriver 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?
Title: Re: Modshop Fix - No collisions
Post by: Fuse 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
Title: Re: Modshop Fix - No collisions
Post by: BikeDriver on June 19, 2014, 01:14:10 AM
I don't get it. What is more unique than the player ID?
Title: Re: Modshop Fix - No collisions
Post by: Runey on June 19, 2014, 09:14:11 AM
Probably that.Fuse knows the best,so better listen to him. :)
Title: Re: Modshop Fix - No collisions
Post by: Fuse 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
Title: Re: Modshop Fix - No collisions
Post by: cripller on June 19, 2014, 01:49:09 PM
Now this is something interesting! :) Good work! n1 mate!