122 line is
Code: Select all
declare ItemArrow = CreateItem(ArrowId);
if delete
Code: Select all
declare ItemArrow = CreateItem(ArrowId);
Moderator: NADEO
Code: Select all
declare ItemArrow = CreateItem(ArrowId);
Code: Select all
declare ItemArrow = CreateItem(ArrowId);
simple this part of codesteeffeen wrote:that's too less information to help you..
how do you set ArrowId?
Code: Select all
// Init variables
UpdatePlayerSpawnQueue();
G_TotalPlayersSpawned = G_PlayerSpawnQueue.count;
declare AutoActivationInProgress = False;
declare OffZoneBonus = G_TotalPlayersSpawned;
declare RoundEndRequested = False;
declare RoundWinnerId = NullId;
declare LastSpawnTime = -S_SpawnInterval * 1000;
declare LastMessageTime = Now;
declare LastUIUpdateTime = -C_UITickPeriod;
declare Goal <=> SM::GetPole("Goal", 0);
///items pickup
ItemList_Begin();
declare ArmorId = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx");
declare RocketId = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
declare LaserId = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
declare NucleusId = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
declare ArrowId = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
ItemList_End();
declare ItemArmor = CreateItem(ArmorId);
declare ItemLaser = CreateItem(LaserId);
declare ItemNucleus = CreateItem(NucleusId);
declare ItemRocket = CreateItem(RocketId);
declare ItemArrow = CreateItem(ArrowId);
***
hmm i am restarted my title pack...logs where i look him?steeffeen wrote:when do you execute this code?
did you try to restart the game after adding the code? (so that's a clean execution)
did you log the content of ArrowId? (maybe it's Null)
Code: Select all
foreach (Event in PendingEvents) {
if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesItem) {
if (Event.Player != Null && Event.Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
AttachItemToPlayer(Event.Item, Event.Player);
// Do something depending on the item
// ...
PassOn(Event);
}
}
}
This part of the code must be executed only once at the beginning of the script, before the loading of the map. From the code you pasted it seems it's in your ***StartMap*** or ***StartRound***. It should be in the ***StartServer*** section. Once it's done, try to restart your server and see if the error persists.ItemList_Begin();
declare ArmorId = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx");
declare RocketId = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
declare LaserId = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
declare NucleusId = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
declare ArrowId = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
ItemList_End();
If you press ctrl+g one time it will open a small log window at the bottom of the screen. Just use the log() function to write inside it.alividerci wrote:hmm i am restarted my title pack...logs where i look him?
Some examples of code to manage items:alividerci wrote:I formed a few questions on this part of the code ...
1. How to verify that you pick up
2. As the selection immediately remove the object and then spawn after a certain time
Thank you for your attention
Code: Select all
// ---------------------------------- //
/** Spawn items
* This function must be called at each frame inside the play loop
*/
Void SpawnItems() {
// Loop on all the items the mapper put on the map
foreach (ItemAnchor in ItemAnchors) {
// Check if an item is already spawn on this anchor
declare ItemSpawned for ItemAnchor = False;
if (ItemSpawned) continue;
// Check if the respawn timer has been reach
declare ItemNextSpawn for ItemAnchor = Now;
if (ItemNextSpawn > Now) continue;
// Create an empty item
declare CSmItem Item;
// Depending on the item anchor tag, assign the right item
switch (ItemAnchor.Tag) {
case "Armor" : Item = CreateItem(ArmorId);
case "Rocket" : Item = CreateItem(RocketId);
case "Laser" : Item = CreateItem(LaserId);
case "Nucleus" : Item = CreateItem(NucleusId);
case "Arrow" : Item = CreateItem(ArrowId);
}
// If the item was correctly created
if (Item != Null) {
// Save from which anchor the item was spawned
declare AnchorId for Item = NullId;
AnchorId = ItemAnchor.Id;
// Save the tag of the anchor in the item
declare Tag for Item = ItemAnchor.Tag;
Tag = ItemAnchor.Tag;
// Spawn the item on the anchor
AttachItemToAnchor(Item, ItemAnchor);
ItemSpawned = True;
}
}
}
// ---------------------------------- //
/** Pick up item
*
* @param _Player The player who picked up the item
* @param _Item The item picked up by the player
*/
Void PickUpItem(CSmPlayer _Player, CSmItem _Item) {
if (_Player == Null || _Item == Null) return;
// Get the tag and the anchor of the item
declare Tag for _Item = "";
declare AnchorId for _Item = NullId;
// Check that the anchor associated with the item really exists
if (!ItemAnchors.existskey(AnchorId)) return;
declare ItemAnchor <=> ItemAnchors[AnchorId];
// We picked up the item, so it's not spawned on the anchor anymore
declare ItemSpawned for ItemAnchor = False;
ItemSpawned = False;
// Update the time of the next item respawn on this anchor
declare ItemNextSpawn for ItemAnchor = Now;
ItemNextSpawn = Now + 45000; ///< Respawn in 45 seconds
// Check the tag associated to the item and do something accordingly
switch (Tag) {
// If it's an armor, reload one armor point
case "Armor": {
_Player.Armor += 100;
}
// If it's a weapon, then switch to this weapon
case "Rocket": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Rocket, False);
}
case "Laser": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Laser, False);
}
case "Nucleus": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Nucleus, False);
}
case "Arrow": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Arrow, False);
}
}
// Attach the item to the player to display the blue flashing screen feedback
AttachItemToPlayer(_Item, _Player);
// Destroy the item after that
DestroyItem(_Item);
}
If I understand you correctly I have to create a separate document and attach these features so?(or this to place in function part)Eole wrote:This part of the code must be executed only once at the beginning of the script, before the loading of the map. From the code you pasted it seems it's in your ***StartMap*** or ***StartRound***. It should be in the ***StartServer*** section. Once it's done, try to restart your server and see if the error persists.ItemList_Begin();
declare ArmorId = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx");
declare RocketId = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
declare LaserId = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
declare NucleusId = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
declare ArrowId = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
ItemList_End();
If you press ctrl+g one time it will open a small log window at the bottom of the screen. Just use the log() function to write inside it.alividerci wrote:hmm i am restarted my title pack...logs where i look him?
Some examples of code to manage items:alividerci wrote:I formed a few questions on this part of the code ...
1. How to verify that you pick up
2. As the selection immediately remove the object and then spawn after a certain time
Thank you for your attentionCode: Select all
// ---------------------------------- // /** Spawn items * This function must be called at each frame inside the play loop */ Void SpawnItems() { // Loop on all the items the mapper put on the map foreach (ItemAnchor in ItemAnchors) { // Check if an item is already spawn on this anchor declare ItemSpawned for ItemAnchor = False; if (ItemSpawned) continue; // Check if the respawn timer has been reach declare ItemNextSpawn for ItemAnchor = Now; if (ItemNextSpawn > Now) continue; // Create an empty item declare CSmItem Item; // Depending on the item anchor tag, assign the right item switch (ItemAnchor.Tag) { case "Armor" : Item = CreateItem(ArmorId); case "Rocket" : Item = CreateItem(RocketId); case "Laser" : Item = CreateItem(LaserId); case "Nucleus" : Item = CreateItem(NucleusId); case "Arrow" : Item = CreateItem(ArrowId); } // If the item was correctly created if (Item != Null) { // Save from which anchor the item was spawned declare AnchorId for Item = NullId; AnchorId = ItemAnchor.Id; // Save the tag of the anchor in the item declare Tag for Item = ItemAnchor.Tag; Tag = ItemAnchor.Tag; // Spawn the item on the anchor AttachItemToAnchor(Item, ItemAnchor); ItemSpawned = True; } } } // ---------------------------------- // /** Pick up item * * @param _Player The player who picked up the item * @param _Item The item picked up by the player */ Void PickUpItem(CSmPlayer _Player, CSmItem _Item) { if (_Player == Null || _Item == Null) return; // Get the tag and the anchor of the item declare Tag for _Item = ""; declare AnchorId for _Item = NullId; // Check that the anchor associated with the item really exists if (!ItemAnchors.existskey(AnchorId)) return; declare ItemAnchor <=> ItemAnchors[AnchorId]; // We picked up the item, so it's not spawned on the anchor anymore declare ItemSpawned for ItemAnchor = False; ItemSpawned = False; // Update the time of the next item respawn on this anchor declare ItemNextSpawn for ItemAnchor = Now; ItemNextSpawn = Now + 45000; ///< Respawn in 45 seconds // Check the tag associated to the item and do something accordingly switch (Tag) { // If it's an armor, reload one armor point case "Armor": { _Player.Armor += 100; } // If it's a weapon, then switch to this weapon case "Rocket": { SetPlayerWeapon(_Player, CSmMode::EWeapon::Rocket, False); } case "Laser": { SetPlayerWeapon(_Player, CSmMode::EWeapon::Laser, False); } case "Nucleus": { SetPlayerWeapon(_Player, CSmMode::EWeapon::Nucleus, False); } case "Arrow": { SetPlayerWeapon(_Player, CSmMode::EWeapon::Arrow, False); } } // Attach the item to the player to display the blue flashing screen feedback AttachItemToPlayer(_Item, _Player); // Destroy the item after that DestroyItem(_Item); }
Code: Select all
foreach (ItemAnchor in ItemAnchors) {
switch (ItemAnchor.ItemName) {
case "SMCommon\\Pickups\\Armor.Item.gbx": {
AttachItemToAnchor(ItemArmor, ItemAnchor);
}
}
}
No, you can used this function directly in your game mode script. This is an example of the functions I use in the Combo mode to pick up items and respawn them at a determined interval.alividerci wrote: If I understand you correctly I have to create a separate document and attach these features so?(or this to place in function part)
This code is also valid and will spawn an armor on the anchor if you have correctly created an ItemArmor before.alividerci wrote: and why this codeCode: Select all
foreach (ItemAnchor in ItemAnchors) { switch (ItemAnchor.ItemName) { case "SMCommon\\Pickups\\Armor.Item.gbx": { AttachItemToAnchor(ItemArmor, ItemAnchor); } } }
The goal of the SpawnItems() function is to spawn items at a determined interval. So if you called it only once at the beginning of your script, then the item won't respawn once a player picked it up. Instead if you call it in the main loop of your game mode then it will verify at each frame if an object can spawn on each ItemAnchor.alividerci wrote: sry but i dont understand what is it mean "This function must be called at each frame inside the play loop"
please give me example if you not busy
Users browsing this forum: No registered users and 1 guest