26.03.2016, 13:43
@lucesita: Please keep in mind that Textdraws can not display special characters, only letters and numbers. You can show us your code and we will take a look at it.
import net.gtaun.shoebill.common.StringUtils; import net.gtaun.shoebill.constant.TextDrawAlign; import net.gtaun.shoebill.constant.TextDrawFont; import net.gtaun.shoebill.data.Color; import net.gtaun.shoebill.event.player.PlayerConnectEvent; import net.gtaun.shoebill.object.Player; import net.gtaun.shoebill.object.PlayerTextdraw; import net.gtaun.shoebill.object.Textdraw; import net.gtaun.shoebill.object.TextdrawBase; import net.gtaun.shoebill.resource.Gamemode; /** * @author lucesita */ public class TextdrawTestGM extends Gamemode { private final String latinString = "Recuperar contraseсa"; @Override protected void onEnable() throws Throwable { getEventManager().registerHandler(PlayerConnectEvent.class, e -> { Player player = e.getPlayer(); player.toggleSpectating(true); // Remove spawn buttons PlayerTextdraw playerTD; playerTD = PlayerTextdraw.create(player, 222.363342f, 30.930297f); playerTD.setLetterSize(0.227482f, 1.369498f); playerTD.setTextSize(40.000000f, 115.287612f); playerTD.setAlignment(TextDrawAlign.get(2)); playerTD.setColor(new Color(-1)); playerTD.setUseBox(true); playerTD.setBoxColor(new Color(84215240)); playerTD.setShadowSize(0); playerTD.setOutlineSize(0); playerTD.setBackgroundColor(new Color(255)); playerTD.setFont(TextDrawFont.get(1)); playerTD.setProportional(true); playerTD.setSelectable(true); playerTD.show(); Textdraw globalTD; globalTD = Textdraw.create(222.363342f, 400.930297f); globalTD.setLetterSize(0.227482f, 1.369498f); globalTD.setTextSize(40.000000f, 115.287612f); globalTD.setAlignment(TextDrawAlign.get(2)); globalTD.setColor(new Color(-1)); globalTD.setUseBox(true); globalTD.setBoxColor(new Color(84215240)); globalTD.setShadowSize(0); globalTD.setOutlineSize(0); globalTD.setBackgroundColor(new Color(255)); globalTD.setFont(TextDrawFont.get(1)); globalTD.setProportional(true); globalTD.setSelectable(true); globalTD.show(player); // 2 tds showed, global at screen bottom, perplayer at screen top playerTD.setText(StringUtils.convertStringForTextdraw("playerTD: " + latinString)); globalTD.setText(StringUtils.convertStringForTextdraw("globalTD: " + latinString)); }); } @Override protected void onDisable() throws Throwable { } }
# Additional plugins
plugins:
- net.gtaun:shoebill-gamemode-reloader:1.0-SNAPSHOT
# Your gamemode
gamemode:dev.acesamp:Gamemode:1.0-SNAPSHOT
/*
* MapAndreas mapAndreas = new MapAndreas(new File(getDataDir(), "SAfull.hmap"));
* float z = mapAndreas.findZ(player.getLocation().x, player.getLocation().y);
* mapAndreas.close();
*
* */
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class MapAndreas
{
private MappedByteBuffer mappedByteBuffer;
public MapAndreas(File mapAndreadData) throws IOException
{
FileInputStream in = new FileInputStream(mapAndreadData);
FileChannel fileChannel = in.getChannel();
mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size());
fileChannel.close();
in.close();
}
public void close()
{
if (mappedByteBuffer == null) return;
synchronized (mappedByteBuffer)
{
mappedByteBuffer = null;
}
}
public float findZ(float x, float y)
{
if (mappedByteBuffer == null) return 0.0f;
if (x < -3000.0f || x > 3000.0f || y > 3000.0f || y < -3000.0f) return 0.0f;
synchronized (mappedByteBuffer)
{
int gridX = ((int) x) + 3000;
int gridY = (((int) y) - 3000) * -1;
int dataPos = (gridY * 6000) + gridX;
mappedByteBuffer.position(dataPos);
int ch1 = Byte.toUnsignedInt(mappedByteBuffer.get()), ch2 = Byte.toUnsignedInt(mappedByteBuffer.get());
return ((float) ((ch2 << 8) + (ch1))) / 100.0f;
}
}
}
try {
mapObject = new MapAndreas(new File(Gamemode.getInstance().getDataDir(), "SAfull.hmap"));
} catch (IOException e) {
e.printStackTrace();
}
public void onPlayerClickMap(Player player, Vector3D pos){
float z = Server.getMapAndreas().findZ(pos.getX(), pos.getY());
player.setLocation(pos.getX(), pos.getY(), z);
}
}
Are you sure that File observation is possible in your environment (not possible on network share for example)? |
[INFO][ResourceManagerImpl] Load plugin: Gamemodereloader [INFO][ResourceManagerImpl] Load gamemode: Gamemode Loading filterscript etc. Number of vehicle models: 132
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 35.409 s [INFO] Finished at: 2016-03-26T18:01:33-06:00 [INFO] Final Memory: 16M/38M [INFO] ------------------------------------------------------------------------ Process finished with exit code 0
[INFO][ResourceManagerImpl] Load plugin: Gamemodereloader [INFO][ResourceManagerImpl] Load gamemode: Gamemode Loading filterscript etc. Number of vehicle models: 132
repositories: - id: central url: http://repo1.maven.org/maven2/nl67425d05...2.60438156 - id: gtaun-public-repo url: http://repo.gtaun.net/content/groups/pub...2.60438156 - id: sonatype-oss-snapshots url: https://oss.sonatype.org/content/reposit...2.60438156# When to update cache? # Options: always / daily / interval:[minutes] cacheUpdatePolicy: daily # If Maven checks for Updates or use old artifacts offlineMode: false # Your needed runtimes runtimes: - net.gtaun:shoebill-runtime:1.2-SNAPSHOT - net.gtaun:shoebill-common:1.2-SNAPSHOT # Additional plugins plugins: - net.gtaun:shoebill-gamemode-reloader:1.0-SNAPSHOT # Your gamemode gamemode: dev.acesamp:Gamemode:1.0-SNAPSHOT
float[] data = new float[]{5f, 1.2f, 35.4f, 21.f}; System.out.println("data length:" + data.length); Object returned = m.call(data, data.length); System.out.println("nativeMethod returned: " + returned);
forward arrayTest(Float:data[], len);
public arrayTest(Float:data[], len)
{
printf("arrayTest called len:%d", len);
for(new i = 0; i < len; i++)
{
printf("i:%d. val:%f", i, data[i]);
}
printf("arrayTest is done");
}
[2016-03-28 22:50:53][INFO][out] data length:4 [2016-03-28 22:50:53][INFO][out] nativeMethod returned: 0 [22:50:53] arrayTest called len:0 [22:50:53] arrayTest is done
jobjectArray ar = (jobjectArray)object; int len = env->GetArrayLength(ar); cell data[10]; for (int i = 0; i < len; i++) { auto o = env->GetObjectArrayElement(ar, i); auto oclass = env->GetObjectClass(o); // This line crashes auto bjf = env->GetMethodID(objectclass, "floatValue", "()F"); auto ffloat = env->CallFloatMethod(object, bjf); data[i] = amx_ftoc(ffloat); }
jfloatArray ar = (jfloatArray)object; int len = env->GetArrayLength(ar); float *fdata = env->GetFloatArrayElements(ar, 0); cell data[10]; for (int i = 0; i < len; i++) { printf("I:%d val:%f\n", i, fdata[i]); data[i] = amx_ftoc(fdata[i]); } env->ReleaseFloatArrayElements(ar, fdata, 0); cell arrCell; amx_PushArray(amx, &arrCell, NULL, data, len);
forward testJavaPawn(Float:values[], valLen, second[], secondLen);
public testJavaPawn(Float:values[], valLen, second[], secondLen)
{
for(new i = 0; i < valLen; i++)
{
printf("Value in Values slot #%i: %f", i, values[i]);
}
for(new i = 0; i < secondLen; i++)
{
printf("Value in Second slot #%i: %i", i, second[i]);
}
return 1;
}
Integer integer = (Integer) myPrimitiveInt;
AmxCallable callback = null;
for(AmxInstance instance : AmxInstanceManager.get().getAmxInstances()) {
if((callback = instance.getPublic("testJavaPawn")) != null)
break;
}
assert callback != null;
Float[] values = new Float[] {5.3f, 12.4f, 5.75f, 7.1f, 88.897f};
callback.call((Object) values); //Cast to Object because of varargs confusion.
//callback.call(values, myNumber); <--- No need to cast because there are 2 parameters.