[Include] PlayerEditArea v1.0 by Maku
#1

PlayerEditArea


Version: 1.0
Author: Maku

Movie: https://www.youtube.com/watch?v=ytY4fML6JN8

Description:
This is a modification of this include - https://sampforum.blast.hk/showthread.php?tid=559910
It works in a similar way, except that it makes it impose zone (rectangle).
Useful tool for dynamic systems.

Functions:
IsPlayerEditArea(playerid); - checks whether the player is in the editor
PlayerEditArea(playerid, areaid); Starts editor for player

Callbacks:
- when a player completes editing area
OnPlayerEditAreaFinish(playerid, areaid, Float:minx, Float:maxx, Float:miny, Float:maxy, success);

- when a player update editing area
OnPlayerEditAreaUpdate(playerid, areaid, Float:minx, Float:maxx, Float:miny, Float:maxy);

Defines:
Код:
#define UNDEFINED_EDITAREA -1 // Nieznane ID range

#define EDITAREA_REASON_SUCCESS 1 //Success in OnPlayerEditAreaFinish (when press FINISHKEY)
#define EDITAREA_REASON_FAIL 0 //success = fail (when player leave from the server or change state)
#define EDITAREA_REASON_CANCEL 2 //success = cancel  (when press CANCELKEY)

#define EDITAREA_FINISHKEY KEY_SECONDARY_ATTACK //Key to accept
#define EDITAREA_CANCELKEY  KEY_JUMP //Key to cancel

#define EDITAREA_OBJECTID 1318 //ID of objects
Download & Example:
http://pastebin.com/EnCUrfN9 - Example
http://pastebin.com/kxFvrKgc - v1.0 (hooking fix)

Calculation the area and the diagonal of zone:
Код:
public OnPlayerEditAreaFinish(playerid, areaid, Float:minx, Float:maxx, Float:miny, Float:maxy, success)
{
    new Float:diagonal = GetDistance2D(maxx, maxy, minx, miny);
    new Float:area = (maxx - minx) * (maxy-miny);
    return 1;
}
 
stock GetDistance2D( Float:x1, Float:y1, Float:x2, Float:y2)
{
    return floatround( floatsqroot( ((x1-x2)*(x1-x2)) + ((y1-y2)*(y1-y2)) ));
}
Reply
#2

At some lines you have forgotten to change ERANGE to EDAREA and hooking doesn't work properly.
Reply
#3

Thanks. New link in first post. When I created this include I edited code from "PlayerEditRange".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)