![]() |
"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 .
|
Quote:
|
i would pos rep you but it wont let me :)
but yea it is, i just don't like using true and false . plus giving them a little exp with it having a value could come in handy later on if he needs to have multi steps to a quest . the unset was just to clean up any loose ends cause my ocd makes me . the not statement tho is just my exp that sometimes != will fail . i did kinda fudge that up as i ment it to be in an if(created or if(playerenters, so if they go back after they got the key it wont still be laying there . my bad |
Quote:
PHP Code:
In GS2 true == 1. But it would be impractical to use that logic and might be confusing to fellow scripters. |
Quote:
|
Quote:
But this isn't working. Maybe I did something wrong??? And i'll start using PHP PHP Code:
|
He just explained why the last script you posted didn't work and how to script it properly instead, and you basically just re-posted it a slightly more broken version of your earlier code.
To clarify when he says 'put in an NPC' he's talking about a level NPC in an actual level. |
Quote:
This is also an "NPC. In an actual level". If you re-read what he posted, You'd understand. Kthxbye |
Quote:
He also then explained the right way to do it, as have a couple others posted their solutions to what you're trying to do. You seem to have ignored or misunderstood that. |
Quote:
Then it only had to do with how to work with IF it's SOLVED/The quest has been done. I can't figure out how to give this player the flag. It seems I can't find threads on it, either. |
You are really overcomplicating things...
Use this server side. PHP Code:
|
Quote:
I thought that was the code to completing this "Mission". Sorry about that. Thank you so much:D |
| All times are GMT +2. The time now is 05:17 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.