Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Check if a player is on a wall. (https://forums.graalonline.com/forums/showthread.php?t=134263995)

Emera 07-24-2011 02:47 PM

Check if a player is on a wall.
 
I have searched the wiki about 5 times now and I still can't find the answer to my question. How do I check if a player is on a wall, in other words on a blocked tile like a wall tile or a roof tile? It may sound a little bit weird asking a simple question like this, but I can't find the answer!

Crow 07-24-2011 03:08 PM

PHP Code:

onwall(float x, float y)
onwall2(float x, float y, float width, float height) 

Keep in mind onwall2() uses the same algorithms as the polygons, making it a bit faulty.

Emera 07-24-2011 03:10 PM

Quote:

Originally Posted by Crow (Post 1660133)
PHP Code:

onwall(float x, float y)
onwall2(float x, float y, float width, float height) 

Keep in mind onwall2 uses the same algorithms as the polygons, making it a bit faulty.

player.onwall player.x, player.y?

Crow 07-24-2011 03:13 PM

Quote:

Originally Posted by Emera (Post 1660135)
player.onwall player.x, player.y?

onwall() is not part of the player object. Also, it will only check for a single pixel. Things like onwall(player.x + 1.5, player.y + 2) are common, since that'd be approximately the center of the player's bounding box.

Tricxta 07-24-2011 11:04 PM

Dusty made a killer thread on this kinda stuff :)
http://forums.graalonline.com/forums...hp?t=134258376

Read up and become a wiz =P

Emera 07-28-2011 01:48 PM

I kept playing around, and this is what I got.
PHP Code:

function onActionServerSide() {
    if (
params[0] == "hacker") {
        
setlevel2("levelname", x, y); //Action after detection
        
echo("[Hack Prevention]: "@player.account@" was caught on a wall."); 
    }
}

//#CLIENTSIDE

function onCreated() {
    
this.admins = 
    {
"wont be affected by onwall"}; //Won't be affected
    
setTimer(0.05); //Starts timer
}

function 
onTimeout() {
    if (
onwall(player.x + 1.5, player.y + 2)) { //Detects if onwall
        
triggerserver("gui", this.name, "hacker");
    } else if (
player.account in this.admins) return;
    
setTimer(1); //Stop RC spam
} 


0PiX0 07-28-2011 02:41 PM

You will want to check
Quote:

Originally Posted by Emera (Post 1660702)
PHP Code:

this.admins = 
    {
"wont be affected by onwall"}; //Won't be affected 


on the server side.

However, it might be better to set a var on staff such as clientr.staff = 1
That way you won't have to list your admins in each system, you can just check player.clientr.staff

Emera 07-28-2011 02:47 PM

True, it would be easier to make it recognize staff members, but it is more customize able if I can enter staff into a field and have it recognize them there. The idea is a good one though, but unfortunately I am no longer working on this. Thank you 0pix0 anyway.

Crow 07-28-2011 04:55 PM

Not a good way to check for wall hackers, and there are quite a few flaws in your code.

cbk1994 07-28-2011 10:50 PM

Quote:

Originally Posted by Emera (Post 1660706)
True, it would be easier to make it recognize staff members, but it is more customize able if I can enter staff into a field and have it recognize them there. The idea is a good one though, but unfortunately I am no longer working on this. Thank you 0pix0 anyway.

It should be done on serverside even if you use an array. As a general rule for writing secure code, assume that anything you write on clientside can be edited by any player.


All times are GMT +2. The time now is 02:39 AM.

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