Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Setting a player's weapon (https://forums.graalonline.com/forums/showthread.php?t=54523)

falco10291029 08-08-2004 04:22 AM

Ok new p[roblem il lcontinue on this thread..... how do you set the players weapon with a script so that the player wuldnt do it manually, i.e a hotkey script?

protagonist 08-08-2004 05:37 PM

Quote:

Originally Posted by falco10291029
Ok new p[roblem il lcontinue on this thread..... how do you set the players weapon with a script so that the player wuldnt do it manually, i.e a hotkey script?

Use keydown and setplayerprop #w, perhaps? I'm not a good scripter yet, so I wouldn't know.

falco10291029 08-08-2004 08:54 PM

setplayerprop#w doesnt work i have tried that that was my first attempt i tried both clientsided and serversided

protagonist 08-08-2004 09:29 PM

Quote:

Originally Posted by falco10291029
setplayerprop#w doesnt work i have tried that that was my first attempt i tried both clientsided and serversided


You could do a check of the client's inventory and use addweapon, since the newest weapon is always the one that is selected first. I don't know if this is secure or not though.

Lance 08-08-2004 09:49 PM

Split to another thread, please refer to the rules.

As for your question, use a for loop to go through the player's weapon IDs, then check if the #w (weaponname) of that ID is the one you want. Hint: #w can take a param in the form of a weapon's ID.

Quote:

Originally Posted by protagonist
Use keydown and setplayerprop #w, perhaps? I'm not a good scripter yet, so I wouldn't know.

If you don't know what you're doing, please don't try to give advice to others.

falco10291029 08-08-2004 10:17 PM

wait what exactly do u mean a for loops? I dont know how it uld set it though pleas ebe a little more clear and sorry i started what shuld have been a diff thread

Lance 08-08-2004 10:26 PM

Quote:

Originally Posted by falco10291029
wait what exactly do u mean a for loops? I dont know how it uld set it though pleas ebe a little more clear and sorry i started what shuld have been a diff thread

This is a for loop:

NPC Code:
for (initial-condition;test-condition;increment-op) {
//put code here that is executed each iteration
}



Read up on for loops to get a good understanding of what each of these parts is, but I will give you another hint for after you have done so: You will want to loop through until the weaponscount. That'll be part of your your test condition.

Loriel 08-08-2004 10:44 PM

Perhaps it is nice to know to do selectedweapon = i too.

Lance 08-08-2004 10:46 PM

Quote:

Originally Posted by Loriel
Perhaps it is nice to know to do selectedweapon = i too.

That would be the coup de grace.

falco10291029 08-08-2004 11:13 PM

um i know how for loops worked i mean how wuold that help u select a wepon theres no command that i know of that will actually set your wepon even if u find the right one!

Lance 08-08-2004 11:35 PM

Quote:

Originally Posted by falco10291029
um i know how for loops worked i mean how wuold that help u select a wepon theres no command that i know of that will actually set your wepon even if u find the right one!

Iterate through weaponscount. Check if #w(yourvar) is the same as the weapon name you want selected. If it is, use the assignment Loriel supplied.

falco10291029 08-09-2004 12:37 AM

ok Let me see if i can get this straight. Your saying I should do smething lilke this for selecting the weapon

NPC Code:

for (i=o;i<weaponscount;i++) {
if (strequals(#w(i),#s(client.letter))///ud have to see my script to get it) {
selectedweapon=i;
break;
}

}




AM I right? Well I will try it.

protagonist 08-09-2004 12:48 AM

Looks right.

falco10291029 08-09-2004 01:07 AM

It works now i just have to fix it up so it works with two ro three word wepon names since it works by a chat command and tokenizing but i can figure that out i think

protagonist 08-09-2004 02:02 AM

Use #e....

VeX_RaT_Boy 08-09-2004 03:00 AM

Quote:

Originally Posted by falco10291029
*script*

AM I right? Well I will try it.

You miss a ')' in the condition there.

Also:
NPC Code:
for (i=o;i<weaponscount;i++)



You have 'o' there not '0' (zero). This works, because the variable 'o' has not been set to anything, so it is zero. But if you need to use the var 'o' once, you shouldn't have it in the for loop... This will not be a problem if you don't set 'o' or you can just use zero there.

falco10291029 08-09-2004 04:33 AM

oh oops and how would i use #e? do u do like #e(6,-3,#c) or soemthing? For now i have it so it tells you to just put quotes around it since that makes it 1 word


All times are GMT +2. The time now is 10:49 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.