blumi Posted February 2, 2019 Share Posted February 2, 2019 Hello to all, I started learning API on the c # serve side. I tried to write a spawn system player. I checked the documentation and found the code: [DisableDefaultOnConnectSpawn] [ServerEvent(Event.PlayerConnected)] public void OnPlayerConnected(Client player) { NAPI.Player.SpawnPlayer(player, new Vector3(2, 5, 8)); // Will spawn the player at the given position } My compiler is showing me an error: the type or namespace “DisableDefaultOnConnectSpawnAttribute” could not be found. Can anybody help me? Thank you in advance Link to comment Share on other sites More sharing options...
Flashrex Posted February 2, 2019 Share Posted February 2, 2019 (edited) Use this: NAPI.Server.SetAutoSpawnOnConnect(false); NAPI.Server.SetAutoRespawnAfterDeath(false); Edited February 2, 2019 by Flashrex Link to comment Share on other sites More sharing options...
blumi Posted February 2, 2019 Author Share Posted February 2, 2019 12 минуты назад, Flashrex сказал: Use this: NAPI.Server.SetAutoSpawnOnConnect(false); NAPI.Server.SetAutoRespawnAfterDeath(false); I tried to do that) But my "OnPlayerConnected" method doesn't work) [ServerEvent(Event.PlayerConnected)] public void OnPlayerConnected(Client player) { Spawn(player); NAPI.Chat.SendChatMessageToAll("~b~ Connected!"); } Link to comment Share on other sites More sharing options...
Flashrex Posted February 2, 2019 Share Posted February 2, 2019 (edited) You need to use it in ResourceStart-Event. https://wiki.gtanet.work/index.php?title=OnResourceStart What is not working exactly? Edited February 2, 2019 by Flashrex Link to comment Share on other sites More sharing options...
blumi Posted February 2, 2019 Author Share Posted February 2, 2019 3 минуты назад, Flashrex сказал: You need to use it in ResourceStart-Event. https://wiki.gtanet.work/index.php?title=OnResourceStart What is not working exactly? OnPlayerConnected-Event wasn't called. Not a single line of code was executed. Link to comment Share on other sites More sharing options...
Flashrex Posted February 2, 2019 Share Posted February 2, 2019 (edited) Show me your console. Did you add :Script after your class name? For example: class Main : Script { //Code } Did you include your resource in your settings.xml? <resource src="myGamemode" /> Edited February 2, 2019 by Flashrex Link to comment Share on other sites More sharing options...
blumi Posted February 2, 2019 Author Share Posted February 2, 2019 (edited) 31 минуту назад, Flashrex сказал: Show me your console. Did you add :Script after your class name? For example: class Main : Script { //Code } Did you include your resource in your settings.xml? <resource src="myGamemode" /> Yes, I did. I can show you my code: using System.Collections.Generic; using GTANetworkAPI; namespace CriminalBelarus { public class Main : Script { private List<Vehicle> _vehicles = new List<Vehicle>(); [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { NAPI.Server.SetAutoSpawnOnConnect(false); NAPI.Server.SetAutoRespawnAfterDeath(false); NAPI.Server.SetDefaultSpawnLocation(new Vector3(-1036.182, -2729.434, 13.75665)); SpawnCars(); NAPI.Util.ConsoleOutput("Criminal Belarus has been loaded!"); } [ServerEvent(Event.PlayerConnected)] public void OnPlayerConnected(Client player) { SpawnPlayer(player); NAPI.Chat.SendChatMessageToAll($"~b~ Hello!"); } private void SpawnPlayer(Client player) { Vector3 spawnPos = new Vector3(-1036.182, -2729.434, 13.75665); NAPI.Player.SpawnPlayer(player, spawnPos); player.Position = spawnPos; player.Health = 100; } private void SpawnCars() { VehicleHash vehcleHash = NAPI.Util.VehicleNameToModel("tribike2"); Vehicle vehicle = NAPI.Vehicle.CreateVehicle(vehcleHash, new Vector3(-1019, -2692.058, 13.99043), 59, 27, 27); Vehicle vehicle2 = NAPI.Vehicle.CreateVehicle(vehcleHash, new Vector3(-1017, -2688.171, 13.99043), 59, 27, 27); _vehicles.Add(vehicle); _vehicles.Add(vehicle2); } } } Yes, I included resuorces in settings.xml OnResourceLoaded-Event was executed, but OnPlayerConnected-Event was not executed. In another script, "welcomemessages" is the default script that the OnPlayerConnected-Event was executed. This is so strange) Edited February 2, 2019 by blumi Link to comment Share on other sites More sharing options...
Flashrex Posted February 2, 2019 Share Posted February 2, 2019 (edited) Are you compiling your resource on .Net Core 2.2? Did you reference the bootstrapper.dll directly or are you using the nuget? (Nuget is outdated) Is the bootstrapper and the bridge both on 0.3.7.0 (look in server-console)? Edited February 2, 2019 by Flashrex Link to comment Share on other sites More sharing options...
blumi Posted February 2, 2019 Author Share Posted February 2, 2019 2 минуты назад, Flashrex сказал: Are you compiling your resource on .Net Core 2.2? Did you reference the bootstrapper.dll directly or are you using the nuget? (Nuget is outdated) Is the bootstrapper and the bridge both on 0.3.7.0 (look in server-console)? I'm compiling resource on .Net Core 2.0. Maybe this is the reason) Here is Console output Image Link to comment Share on other sites More sharing options...
Flashrex Posted February 2, 2019 Share Posted February 2, 2019 (edited) I found that on Discord: Zitat you need to replace the bootstrapper.dll in RAGEMP\server-files\bridge\runtime with the one from your gtanetwork.api nuget package Edited February 2, 2019 by Flashrex Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now