Git Product home page Git Product logo

Comments (12)

Y-Less avatar Y-Less commented on July 23, 2024

You need the string: tag:

foreign string:getSomeString();

global string:getSomeString() {
 new test[20];
 test = "Some String";
 return test;
}

FYI, there is also a void: tag if you don't want to return anything at all.

from ysi-includes.

Y-Less avatar Y-Less commented on July 23, 2024

Not that if you get a string size mismatch, use YSI_MAX_STRING for the string size instead.

from ysi-includes.

DeTTer avatar DeTTer commented on July 23, 2024

Thanks a lot.

One more thing.
If i have same native functions (except OnFilterScriptInit) in multiple filterscripts (e.g. OnPlayerConnect) ,only the first one (in "server.cfg") gets called.

from ysi-includes.

Crayder avatar Crayder commented on July 23, 2024

What are you returning?

from ysi-includes.

DeTTer avatar DeTTer commented on July 23, 2024

I tried with '0' and '1'.

About string as return.
When i use fuction with "string" tag outside of filterscript (where that func. is defined) i get run time error (Invalid memory access) (it works fine while used inside fs).

from ysi-includes.

Y-Less avatar Y-Less commented on July 23, 2024

Make sure the Filterscript is compiled as YSIM_IS_MASTER and the gamemode as YSIM_IS_STUB (or YSIM_IS_CLIENT).

from ysi-includes.

DeTTer avatar DeTTer commented on July 23, 2024

I tried with YSIM_IS_MASTER ,STUB ,CLIENT and SERVER and can't seem to get strings working.

global GetInt() 
    return 15;

global string:GetString() {
    new test[YSI_MAX_STRING] = "Please Work";
    return test;
}

global bool:GetBool() 
    return true;

With this (in the main script) i get:

15
RUN TIME ERROR
1

from ysi-includes.

Y-Less avatar Y-Less commented on July 23, 2024

I would need to see more of both your server and client code, also what the run time error is and where.

from ysi-includes.

DeTTer avatar DeTTer commented on July 23, 2024

This is stripped down version of my scripts.

  • This is the main script:
#include <a_samp>
#include <YSI\y_timers>

#define YSIM_IS_STUB
#define MASTER 1
#include <YSI\y_master>

#include <mytest>

main() {
    print("Main started.");
}

public OnGameModeInit() {
    defer test1();
    defer test2();
    return 1;
}

timer test1[1000]() {
    printf("GetInt: %i" ,GetInt() );
}
timer test2[2000]() {
    printf("GetString: %s" ,GetString() );
}
  • 1st FS (test.pwn)
#include <a_samp>

#define MASTER 2
#define YSIM_IS_MASTER  
#include <YSI\y_master>

#include <mytest>

public OnFilterScriptInit() { 
    print("Test.pwn started");
    return 1;
}

global GetInt()
    return 42;

global string:GetString() {
    new test[YSI_MAX_STRING] = "Some String";
    return test;
}
  • 2nd FS (otherFS.pwn)
#include <a_samp>
#include <YSI\y_timers>

#define MASTER 3
#define YSIM_IS_MASTER  
#include <YSI\y_master>

#include <mytest>

public OnFilterScriptInit() { 
    print("otherFS.pwn started");
    defer test1();
    defer test2();
    return 1;
}

timer test1[4000]() {
    printf("From otherFS: %i" ,GetInt() );
}
timer test2[5000]() {
    printf("From otherFS: %s" ,GetString() );
}
  • mytest.inc
foreign GetInt();
foreign string:GetString();

With this code i get:

42
RUN TIME ERROR (invalid memory access)
From otherFS: 42
RUN TIME ERROR (invalid memory access)

Errors are detected by crashdetect plugin.
(sorry i don't know how to fold text)

from ysi-includes.

Crayder avatar Crayder commented on July 23, 2024

I'm pretty sure you can't have 2 masters...

from ysi-includes.

Y-Less avatar Y-Less commented on July 23, 2024

No, you can't. You can, however, set one script as server for one MASTER and another for another.

from ysi-includes.

DeTTer avatar DeTTer commented on July 23, 2024

But even when i had only one FS (one master) i was still getting the same error.

from ysi-includes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.