Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   General Graal Discussion (https://www.graalians.com/forums/forumdisplay.php?f=2)
-   -   Script Help (https://www.graalians.com/forums/showthread.php?t=7064)

The Doctor 06-05-2012 03:23 AM

I have summed this up by doing this:
PHP Code:

function onPlayerTouchsMe(){
if (
player.account in serveroptions.staff) {
setlevel2("futustia-bar.nw"10.544.5);
player.dir 2;
}
else {
player.chat "I am not staff. I cannot be in this bar.";
}


I have learned alot being around you guys <3

Twinny 06-05-2012 10:10 AM

Lol whoops. My bad on that one :-)

The Doctor 06-06-2012 02:17 AM

Amazing what you can do with scripts. I made an NPC in a small staff room guarded by that staff only script. The NPC inside gives whoever touches it the default staff weapons.

Twinny 06-06-2012 09:31 AM

Quote:

Posted by Shawn (Post 134498)
Amazing what you can do with scripts. I made an NPC in a small staff room guarded by that staff only script. The NPC inside gives whoever touches it the default staff weapons.

O_o thats not a good method. Players can memory edit level links to warp them anywhere. You should only add staff weapons via RC

The Doctor 06-06-2012 11:27 AM

I though't I'd be easier. I can always make the Control NPC add weapons to staff when they log in.

Emera 06-06-2012 12:01 PM

Quote:

Posted by Shawn (Post 134815)
I though't I'd be easier. I can always make the Control NPC add weapons to staff when they log in.

That'd be your best bet. Just list them in an array and add them to the staff members as they login.
PHP Code:

for (wep this.staff_weps) {
  if (
player.clientr.isStaffplayer.addweapon(wep);


Obviously, you'll have to set up giving staff the clientr.isStaff flag so it knowns if to add weapons or not. You could always read from serveroptions.staff and check if their account is inside the list.

PHP Code:

temp.staff serveroptions.staff.tokenize(",");
if (
player.account in temp.staff || player.communityname in temp.staff) {
  
player.clientr.isStaff true;


And I don't want to be the one to nag, but you really need to learn how to style your code. You can read into decent styling techniques in this official forums thread by Skyld, and you can also use FP4's GS2 beautifier. Obviously, styling code is pretty much personal preference, but it makes it easier to read if you adapt to using a clean and readable style so other coders can look through it with ease. Other than that, good job. You're making progress.

The Doctor 06-06-2012 10:31 PM

I don't like indenting my code. Tried it in PHP, didn't make a difference to me. But I'll try from now on :)

xXziroXx 06-07-2012 12:10 AM

Quote:

Posted by Emera (Post 134830)
PHP Code:

for (wep this.staff_weps) {
  if (
player.clientr.isStaffplayer.addweapon(wep);



Don't ever do that. It's -really- important to assign wep as a temporary variable, right now it's not. It's also very important to name your variables logically instead of taking shortcuts in order to get the names as short as possible. You'll thank me for that last piece of advice in a year or two when you go back and look at your old code.

There's little to no reason to keep the weapon list stored in a permanent array, so I'd change that too to a temporary one.

I also hate that styling, but then again it comes down to personal preference in this case.

Correct way, with my personal touch to it:

PHP Code:

temp.listOfStaffWeapons = {
  
"Weapon1",
  
"Weapon2",
  
"Weapon3"
}

for (
temp.weaponNametemp.listOfStaffWeapons) {
  if (
player.clientr.isStaff)
    
player.addWeapon(temp.weaponName);




Quote:

Posted by Shawn (Post 135127)
I don't like indenting my code. Tried it in PHP, didn't make a difference to me. But I'll try from now on :)

Good luck getting anywhere on Graal as a programmer without using proper indenting and styling.

The Doctor 06-07-2012 02:14 AM

What difference does it make, other than making it pretty?

BboyEatsbacon 06-07-2012 02:31 AM

Quote:

Posted by Shawn (Post 135283)
What difference does it make, other than making it pretty?

  • Easier to refer back to
  • Can read without being easily thought scattered
  • Looks Neat
  • Programmers will hate you if you don't

The Doctor 06-07-2012 02:35 AM

Quote:

Posted by BboyEatsbacon (Post 135301)
  • Programmers will hate you if you don't

I could imagine Skyld raging at me or something O.o

xXziroXx 06-07-2012 02:37 AM

Quote:

Posted by Shawn (Post 135307)
I could imagine Skyld raging at me or something O.o

Skyld wouldn't accept a script like that to be uploaded to begin with.

The Doctor 06-07-2012 02:40 AM

It's because I'm beginner and he expects something that comes from a pro.

Skyld 06-08-2012 02:17 AM

Quote:

Posted by Shawn
It's because I'm beginner and he expects something that comes from a pro.

Actually it's because I'm not going to waste my time trying to make heads or tails of terribly formatted code, not because you are a beginner, but because it's just hard to read. If you format your code properly, it makes it easier for other people to understand, and as a result, we will be more willing to help you.

xXziroXx 06-08-2012 02:30 AM

Quote:

Posted by Skyld (Post 136085)
Actually it's because I'm not going to waste my time trying to make heads or tails of terribly formatted code, not because you are a beginner, but because it's just hard to read. If you format your code properly, it makes it easier for other people to understand, and as a result, we will be more willing to help you.

Oh wow, it has an account here! I am surprised.


All times are GMT. The time now is 11:49 PM.

Powered by vBulletin/Copyright ©2000 - 2025, vBulletin Solutions Inc.