Author Topic: Blocking Item Spawning  (Read 1724 times)

Can someone explain why this doesn't work?

Code: [Select]
package RP_Noitems {
  
  function fxDtsBrick::spawnItem(%brick, %pos, %datablock, %client)
{
  if(!isObject(%datablock)) {
     parent::spawnItem(%brick, %pos, %datablock, %client);
     return;
    }
     messageClient(%client, '', "\c6You cannot just spawn an item.");
     return;
}
  
};

activatePackage(RP_Noitems);

This is at the very end I put this at the end of the server.cs of Iban's CityRPG.
« Last Edit: April 09, 2011, 11:43:19 PM by Giovan »

I did not write whatever the forget that is supposed to be. People need to stop adding stuff to CityRPG and leaking it all over the place, I get mis-credited with god awful code.

Source: GameMode_CityRPG/server.cs
Code: [Select]
// Banned Events
unRegisterOutputEvent("fxDTSBrick", "RadiusImpulse");
unRegisterOutputEvent("fxDTSBrick", "SetItem");
unRegisterOutputEvent("fxDTSBrick", "SetItemDirection");
unRegisterOutputEvent("fxDTSBrick", "SetItemPosition");
unRegisterOutputEvent("fxDTSBrick", "SetVehicle");
unRegisterOutputEvent("fxDTSBrick", "SpawnExplosion");
unRegisterOutputEvent("fxDTSBrick", "SpawnItem");
unRegisterOutputEvent("fxDTSBrick", "SpawnProjectile");

unRegisterOutputEvent("Player", "AddHealth");
unRegisterOutputEvent("Player", "AddVelocity");
unRegisterOutputEvent("Player", "BurnPlayer");
unRegisterOutputEvent("Player", "ChangeDatablock");
unRegisterOutputEvent("Player", "ClearBurn");
unRegisterOutputEvent("Player", "ClearTools");
unRegisterOutputEvent("Player", "Dismount");
unRegisterOutputEvent("Player", "InstantRespawn");
unRegisterOutputEvent("Player", "Kill");
unRegisterOutputEvent("Player", "SetHealth");
unRegisterOutputEvent("Player", "SetPlayerScale");
unRegisterOutputEvent("Player", "SetVelocity");
unRegisterOutputEvent("Player", "SpawnExplosion");
unRegisterOutputEvent("Player", "SpawnProjectile");

unRegisterOutputEvent("GameConnection", "IncScore");
unRegisterOutputEvent("GameConnection", "ChatMessage");

unRegisterOutputEvent("MiniGame", "BottomPrintAll");
unRegisterOutputEvent("MiniGame", "CenterPrintAll");
unRegisterOutputEvent("MiniGame", "ChatMsgAll");
unRegisterOutputEvent("MiniGame", "Reset");
unRegisterOutputEvent("MiniGame", "RespawnAll");

I did not write whatever the forget that is supposed to be. People need to stop adding stuff to CityRPG and leaking it all over the place, I get mis-credited with god awful code.
i know right


make your own if you want to script a cityRPG so badly.

Anyways, is unRegisterOutputEvent a real function?

I never knew about it.  :cookieMonster:

i know right


make your own if you want to script a cityRPG so badly.

Anyways, is unRegisterOutputEvent a real function?

I never knew about it.  :cookieMonster:
Code: [Select]
   virtual Script unRegisterOutputEvent() {}
   virtual Script registerOutputEvent() {}
Yep.

No, I just made it up off the top of my head and it worked.

No, I just made it up off the top of my head and it worked.
you're a wizard.

anyways, wow that would be a useful function to know about in the future.

I did not write whatever the forget that is supposed to be. People need to stop adding stuff to CityRPG and leaking it all over the place, I get mis-credited with god awful code.

Source: GameMode_CityRPG/server.cs
Code: [Select]
// Banned Events
unRegisterOutputEvent("fxDTSBrick", "RadiusImpulse");
unRegisterOutputEvent("fxDTSBrick", "SetItem");
unRegisterOutputEvent("fxDTSBrick", "SetItemDirection");
unRegisterOutputEvent("fxDTSBrick", "SetItemPosition");
unRegisterOutputEvent("fxDTSBrick", "SetVehicle");
unRegisterOutputEvent("fxDTSBrick", "SpawnExplosion");
unRegisterOutputEvent("fxDTSBrick", "SpawnItem");
unRegisterOutputEvent("fxDTSBrick", "SpawnProjectile");

unRegisterOutputEvent("Player", "AddHealth");
unRegisterOutputEvent("Player", "AddVelocity");
unRegisterOutputEvent("Player", "BurnPlayer");
unRegisterOutputEvent("Player", "ChangeDatablock");
unRegisterOutputEvent("Player", "ClearBurn");
unRegisterOutputEvent("Player", "ClearTools");
unRegisterOutputEvent("Player", "Dismount");
unRegisterOutputEvent("Player", "InstantRespawn");
unRegisterOutputEvent("Player", "Kill");
unRegisterOutputEvent("Player", "SetHealth");
unRegisterOutputEvent("Player", "SetPlayerScale");
unRegisterOutputEvent("Player", "SetVelocity");
unRegisterOutputEvent("Player", "SpawnExplosion");
unRegisterOutputEvent("Player", "SpawnProjectile");

unRegisterOutputEvent("GameConnection", "IncScore");
unRegisterOutputEvent("GameConnection", "ChatMessage");

unRegisterOutputEvent("MiniGame", "BottomPrintAll");
unRegisterOutputEvent("MiniGame", "CenterPrintAll");
unRegisterOutputEvent("MiniGame", "ChatMsgAll");
unRegisterOutputEvent("MiniGame", "Reset");
unRegisterOutputEvent("MiniGame", "RespawnAll");

But even with that, people can just spawn an item without events.

It's a giant, gaping hole.


No, I just made it up off the top of my head and it worked.
I wouldn't doubt it. I bet badspot put it in the day you thought of using it. And silently updated everyone.
« Last Edit: April 09, 2011, 11:44:33 PM by Giovan »

I did not write whatever the forget that is supposed to be. People need to stop adding stuff to CityRPG and leaking it all over the place, I get mis-credited with god awful code.

I'm quite sorry, I didn't mean to imply that you wrote that.

Suggestion: Stop being a stuffty host and disable add-ons that are"giant, gaping holes."

The only add-ons I have enabled with my version of CityRPG are: CityRPG, and a bunch of brick packs. Everything is perfectly balanced with the gamemode itself, including weapons.

Suggestion: Stop being a stuffty host and disable add-ons that are"giant, gaping holes."

The only add-ons I have enabled with my version of CityRPG are: CityRPG, and a bunch of brick packs. Everything is perfectly balanced with the gamemode itself, including weapons.

I'd think my set-up is the same.

Can I have some coding help instead of hosting help now, please?
« Last Edit: April 09, 2011, 11:49:26 PM by Giovan »

It's possible, I'm sure.

I'm not sure where to direct you for an example, though.

I thought my code was an example. It doesn't work, though. Could you help me fix it?

Hint: I stole part of this from RP Content - Items cost money.

hm, let me make some adjustments then.

Code: [Select]
package RP_Noitems {
   
  function fxDtsBrick::spawnItem(%brick, %pos, %datablock, %client)
{
   if(%client.isAdmin || %client.isSuperAdmin)
      parent::spawnItem(%brick, %pos, %datablock, %client);
                 else
     messageClient(%client, '', "\c6You cannot just spawn an item.");
}
   
};

activatePackage(RP_Noitems);

I just remembered something. When you spawn an item, and pick it up, it goes away forever. Maybe Iban is already hijacking the item script?

You are a complete and total loving moron.

There are no other crazy hacks or exceptions in CityRPG v3's code that disable item spawning because I am not a god damn idiot and do not run add-ons that are exploitable.

Unregistering events that people need not be using is the best solution to this problem for your scenario. Admins do not need to be excluded because admins can spawn items at their own leisure.