"If player has" Scripting
I'm trying to make it so that "If this player has this weapon, Then you can do this".
For instance, You find a guy. This guy gives you a key. You go up to a door (without this key) and it doesn't work. But you go up to it (with this key) and it opens linking to another level. That was just an example. I want this to work for many things like, You buy this item, And you are then able to have access to a room. All I can think of script-wise is findweapon("key"); then I have NO idea at ALL what script would come come after for searching this players weapons. It's got to be like, Find the weapon, If found, The door will open, If not, it will say "You are not Authorized" or something. Help? I have no clue what to do..:cry: |
You could check a clientr variable...
player.clientr.quest_dungeonkey = 1; .. if(player.clientr.quest_dungeonkey) { // next level }else{ // Not authorized } Obviously you would change the names to something that would keep your clientr variables organised. |
Quote:
Is dungeonkey the name of the item in the script you've listed? What's variable 1 for? The rest of it I can figure out with this=) |
Quote:
|
Quote:
|
Quote:
The reason I didn't post an explanation of variables is because doing so would be redundant and a waste of my time. That information has already been compiled into Jer's scripting guide. If you're not interested in becoming a better scripter, and are just interested in getting things done, this is not the forum for you. |
Quote:
error 2 : if you weren't new you would already know how to use flags,values and find weapons . error 3 : if your gonna insult the community members expect to spend a lot of your time looking up said info on the net or through a series of trial and error in game to work out how to do something cause you done pissed off the people trying to help you . |
Quote:
|
Quote:
2. I'm not new to scripting, I'm newer to NPC scripting 3. I didn't insult, I simply stated that if he wasn't going to help, It's a waste of everyone's time to even look at his posts. They don't help, And I know they don't because if he posts a link, It ends up having nothing at all to do with the question asked. I read the link, And it had no reference what-so-ever. So "Pissing off the people trying to help you" Doesn't work, Because he's not help.;) |
This is the gist of storing a 'key' as a flag instead of using a weapon.
Key NPC: PHP Code:
PHP Code:
Documentation: clientr variable explanation Logic and conditional statements |
Alright so I did have a little help.
But for some reason even the help couldn't find this problem? function onActionserverside(NULL) { switch (params[0]) { case "givekey": { if (clientr.quest1 == NULL){ clientr.quest1=1; clientr.items.key1=1;} } break; } } //#CLIENTSIDE function onPlayertouchsme() { player.chat = "Test"; message Test; triggerserver("gui", name, "givekey"); } This doesn't set anything into my flags. Why??? |
Once again, please put your code in PHP tags. Cleaning up a little bit and commenting some basic problems:
PHP Code:
Assuming it's in a weapon, when would onPlayerTouchsMe ever get called? A weapon isn't an object in-game; it's a background script that runs on the client. It has no physical representation, and hence nothing to touch. This will never be called. So, the best way to do this is to move your code into an NPC. Then, when the NPC is touched, you'll notice that the player and the NPC both say "Test", but that the trigger never reaches serverside. If you've read about triggers, you'll know why. The trigger is being sent to a weapon with the NPC's name, but that weapon doesn't exist. In addition to that, level NPC names are arbitrary and somewhat unpredictable. Normally you'd need to trigger serverside on the NPC instead, but this is a pain. In your case, it's actually a lot simpler than that: onPlayerTouchsMe is called serverside in addition to clientside, so there's no need to communicate between them. We can simplify your code: PHP Code:
PHP Code:
|
i fail to see why it even needs to trigger serverside or be done from a weapon for that matter . if your worried about someone hacking the flag through client you might as well just stop now cause it is gonna happen at some point and trying to prevent even one person from doing so is just wasting time .
add npc to level, set img to a key . insert code PHP Code:
PHP Code:
|
Quote:
|
that's for clearing up why . it may not be perfect but i threw it together in less then a minute . it's a lot simpler and when you wanna teach someone to ride a bide you might not want to take off the training wheels right away.... or just throw em on a motorbike .
|
All times are GMT +2. The time now is 11:24 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.