updating a script that's already a weapon

So if I want to make a -System weapon that every user will have attached, what happens if I then want to update this weapon?

Will every player who has this weapon get the updated script?

And what is the best way to apply a system weapon like that? Just stick it in the default start location and “if playerenteres() { toweapons }”?

delete the weapon for yourself, then use toweapons to get the new weapon… it will update for everyone. Also just to cover myself from spooon type /reloadweapons in rc chat

That’s if you change a weapon file. >:|

if(playertouchsme && hasweapon (#w,weapon name)){ triggeraction gr.removeweapon,weaponname,0,0; toweapons weaponname; }

if(playertouchsme && hasweapon (#w,weapon name)){ triggeraction gr.deleteweapon,weaponname,0,0; toweapons weaponname; }
Fixed, for realz this time :eek:

Create a server string for the version of the system. Each time you update it change the version number. Have some form of a check in the weapon which checks if the version matches the server string if not use the gr.addweapon trigger hack and hopefully it’ll update.

Or just make a system weapon that doesn’t need to be updated and reupdates weapons. That’s what we did on Xialza. First it removed the specified weapon, then it readded it. Worked on a playerenters so that it wouldn’t cause major lag. (It ran off of a server string)

Now that I think about it, an array would be better. Not sure how you would go about scripting that. Meh, not my problem lol.


Uhhhh dude the weapon system for updating didnt run off server strings…

I thought you guys just edited the weaponsSwords/Sword files.



Look fimilar? I was saying that the update ran off of server strings.

oh…that wasnt a weapon updater though… that was for adding and deleting weapons on a serverside bases

Exactly. That’s what this person is asking for, at least from what I think.

no his problem is he wants to update all weapons. What he doesnt know is that update one, and that updates all. So what you do is you delete the weapon from yourself in RC and get the weapon again using the new script and wallah! everyones weapon updated magically

Oh, I thought he meant something else. x_x My bad…

Haha, yeah, sorry for the confusion. What I was asking was something like:
if I make a system weapon that everybody has and then 2 months from now I find a terrible bug in my code, how do I get my code fix into everybodies system weapon.

It sounds like I just need to delete the weapon from myself and then enter the default level to get it back and it will load the updated system weapon to everyone… that seems weird.

Let’s say we have two players, Jack and Jill. Jack finds a weapon that when fired, infinite loops and say2’s through the a,b,c’s. Now, I update this weapon so instead it loops forever through counting 1 to 10. Now Jill enters the server and gets this new updated weapon. Will Jack’s running script stop mid-way through the a,b,c’s and start counting 1 to 10? Or will it just stop and not do anything until fired again?

This seems like strange behavior.

Jack has to reconnect for the weapon to work correctly (for him) after Jill gets the updated weapon.

so, at any given time, if one person gets and “updated” script, everybody else on the server (once they reconnect) will get the new weapon. But, if I reconnect but nobody has been given the new weapon yet, I will not get the newest weapon.

… What on earth is going on behind the scenes here?!

Well, it really depends on how they aquire the weapon.

The client has to recache the weapon either by re-entering the level (if it’s given on playerenters or via similar method) or reconnect if it’s given as a default (it’s given when the account is made which can be accomplished by editing defaultaccount) or purchase (unless they buy the weapon again)

The gserver keeps a list of weapons. Whenever a client requests a weapon, the gserver checks the weapon’s mod time from its internal cache against the mod time of the level the NPC that gives you the weapon is on. If they differ, the gserver re-sends the weapon to every player on the server.

// Check and see if the weapon has changed recently.  If it has, we should
// send the new NPC to everybody on the server.  After updating the script, of course.
if (weapon->getModTime() < npc->getLevel()->getModTime())
    // Update Weapon
    weapon->updateWeapon(server, npc->getProp(NPCPROP_IMAGE).subString(1), npc->getClientScript(), npc->getLevel()->getModTime());

    // Send to Players

The NC_UpdateWeapon() function deletes the weapon and re-adds it.

So, if you want the NPC to be update for everybody, save the level, upload it, call update level, then grab the NPC again.
Let me check and see what happens for a weapon that doesn’t exist in a level…
If you don’t keep weapons in levels, use the RC command /reloadweapons. However, I just noticed that /reloadweapons doesn’t call NC_UpdateWeapon() to update the weapon for all the players. I just now added that command so it should work properly now.