Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] Users Can Spawn Cars On PVE Servers

Junior Spellweaver
Joined
Jan 5, 2015
Messages
173
Reaction score
194
Search :
Code:
if (strncmp(cmd, "/vspawn", 7) == 0 && plr->profile_.ProfileData.isDevAccount)        return Cmd_VehicleSpawn(plr, cmd);

Add Below :
Code:
//RageZone Unique
if (strncmp(cmd, "/spawncar", 7) == 0 && plr->loadout_->GameMapId == GBGameInfo::MAPID_WZ_PVE)
        return Cmd_VehicleSpawn(plr, cmd);

Search:
Code:
 Cmd_VehicleSpawn

You Will See This Code

Code:
int ServerGameLogic::Cmd_VehicleSpawn(obj_ServerPlayer* plr, const char* cmd)
{
    char buf[128];
    int vehicleType = 0;


    if(2 != sscanf(cmd, "%s %d", buf, &vehicleType))
        return 1;


    if (vehicleType < 0 || vehicleType > 3)
        return 1;


    r3dVector position = plr->GetPosition();
    position.x += 3.0f;


    char name[28];
    sprintf(name, "Vehicle_%d_%p", obj_Vehicle::s_ListOfAllActiveVehicles.size() + 1, this);


    obj_Vehicle* vehicle = (obj_Vehicle*)srv_CreateGameObject("obj_Vehicle", name, position);
    vehicle->SetNetworkID(gServerLogic.GetFreeNetId());
    vehicle->NetworkLocal = true;
    vehicle->spawnObject = 0;
    vehicle->spawnIndex = -1;
    vehicle->SetVehicleType((obj_Vehicle::VehicleTypes)vehicleType);
    vehicle->SetRotationVector(plr->GetRotationVector());
    vehicle->OnCreate();


    r3dOutToLog("[%s] Admin has spawned a vehicle.\n", plr->userName);


    return 0;
}

Make it Look Like

Code:
int ServerGameLogic::Cmd_VehicleSpawn(obj_ServerPlayer* plr, const char* cmd)
{
    char buf[128];
    int vehicleType = 0;


    if(2 != sscanf(cmd, "%s %d", buf, &vehicleType))
        return 1;


    if (vehicleType < 0 || vehicleType > 2)
        return 1;


    r3dVector position = plr->GetPosition();
    position.x += 4.0f;


    char name[28];
    sprintf(name, "Vehicle_%d_%p", obj_Vehicle::s_ListOfAllActiveVehicles.size() + 1, this);


    obj_Vehicle* vehicle = (obj_Vehicle*)srv_CreateGameObject("obj_Vehicle", name, position);
    vehicle->SetNetworkID(gServerLogic.GetFreeNetId());
    vehicle->NetworkLocal = true;
    vehicle->spawnObject = 0;
    vehicle->spawnIndex = -1;
    vehicle->SetVehicleType((obj_Vehicle::VehicleTypes)vehicleType);
    vehicle->SetRotationVector(plr->GetRotationVector());
    vehicle->OnCreate();


    r3dOutToLog("[%s]  spawned a vehicle.\n", plr->userName);


    return 0;
}

Build Server

Then Users Can Spawn Cars On WZ_PVE With /spawncar Command

//PunisherZ Developer
 
Joined
Apr 23, 2013
Messages
1,172
Reaction score
1,795
Work DoommoV3 ??


----------------------------------------------------------

just to show that he has changed in the above code

Code:
int ServerGameLogic::Cmd_VehicleSpawn(obj_ServerPlayer* plr, const char* cmd)
{
    char buf[128];
    int vehicleType = 0;




    if(2 != sscanf(cmd, "%s %d", buf, &vehicleType))
        return 1;




[COLOR=#0000ff]    if (vehicleType < 0 || vehicleType > 2) // [/COLOR][COLOR=#008000]3[/COLOR]
        return 1;




    r3dVector position = plr->GetPosition();
[COLOR=#008000]    position.x += 4.0f; // 3.0f[/COLOR]




    char name[28];
    sprintf(name, "Vehicle_%d_%p", obj_Vehicle::s_ListOfAllActiveVehicles.size() + 1, this);




    obj_Vehicle* vehicle = (obj_Vehicle*)srv_CreateGameObject("obj_Vehicle", name, position);
    vehicle->SetNetworkID(gServerLogic.GetFreeNetId());
    vehicle->NetworkLocal = true;
    vehicle->spawnObject = 0;
    vehicle->spawnIndex = -1;
    vehicle->SetVehicleType((obj_Vehicle::VehicleTypes)vehicleType);
    vehicle->SetRotationVector(plr->GetRotationVector());
    vehicle->OnCreate();




[COLOR=#ff0000]    r3dOutToLog("[%s] spawned a vehicle.\n", plr->userName); // Admin has [/COLOR][COLOR=#FF0000]spawned a vehicle.[/COLOR]




    return 0;
}
 
Back
Top