SAMPProjects / Open-SAMP-API

An open source API for GTA SA:MP
GNU Lesser General Public License v3.0
63 stars 15 forks source link

Add WorldToScreen #18

Closed 0x320 closed 9 years ago

0x320 commented 9 years ago

Könnt ihr euch vielleicht an die Funktion Namens WorldToScreen ransetzen ? Währe Super toll wen Ihr das machen würdet.

Gruß, 0x320

agrippa1994 commented 9 years ago

@MarcelGerber, would you be so kind to take a look at this? I'm not at home atm

marcelgerber commented 9 years ago

I'll try to get to it this week.

0x320 commented 9 years ago

Okay, thanks. After you add this Function, i can Download it on Github ?

mschnitzer commented 9 years ago

You can download the source code on GitHub. Since there is currently no official release of the API, you have to wait for the binaries or compile it by yourself.

0x320 commented 9 years ago

The Source with the WorldToScreen Function comes out and i must Compile it, right ?

agrippa1994 commented 9 years ago

Implemented (https://github.com/SAMPProjects/Open-SAMP-API/commit/a84e2557be1439c63393c3383ce6de8154d14b29) (Binaries are uploaded too)

Example (gta_world.ahk):

#SingleInstance, force
#NoEnv
#include ..\..\include\AHK\SAMP_API.ahk

text_overlay :=- 1

Gui, Show, w200 h50, World functions

SetTimer, Timer, 10
return

; Delete the overlay if the application will be closed by the user
GuiClose:
if(text_overlay != -1)
    TextDestroy(text_overlay)
ExitApp

; Timer callback
Timer:
if(text_overlay == -1) {
    text_overlay := TextCreate("Arial", 30, false, false, -1, -1, 0xFFFF0000, "X", true, true)

    ; Every overlay object is rendered for a resolution of 800 x 600
    ; If you want to disable this kind of calculation, you can do this via "SetOverlayCalculationEnabled"
    ; We've to do this here because WorldToScreen returns the physical pixel coordinates on your screen
    SetOverlayCalculationEnabled(text_overlay, false)
}

if(text_overlay == -1)
    return

; Draw the overlay at the farm in Redwood
if(WorldToScreen(0, 0, 0, x, y)) {
    if(TextSetPos(text_overlay, x, y) == 0) {
        TextDestroy(text_overlay)
        text_overlay := -1
    }
}
return
0x320 commented 9 years ago

Whoo, thanks. :dancer: