SA-MP Forums Archive
Validating models - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP DL Edition (https://sampforum.blast.hk/forumdisplay.php?fid=92)
+--- Forum: SA-MP 0.3.DL (https://sampforum.blast.hk/forumdisplay.php?fid=90)
+--- Thread: Validating models (/showthread.php?tid=645781)



Validating models - Crayder - 04.12.2017

Is there a way to validate models before using them with the pawn functions?


Re: Validating models - beckzy - 04.12.2017

I believe they're validated internally. I could be wrong.

Quote:
Originally Posted by Kalcor
View Post
SA-MP 0.3.8 RC3-3 Client update

- More dff/txd validation.



Re: Validating models - Crayder - 04.12.2017

Quote:
Originally Posted by BeckzyBoi
View Post
I believe they're validated internally. I could be wrong.
Yes but doesn't it seem necessary to know whether a model is valid or not with the server? Like... If I had a command that created objects, I would want to know if models are valid within the script to know whether or not the players should be able to create the model they requested.


Re: Validating models - beckzy - 04.12.2017

Quote:
Originally Posted by Crayder
View Post
Yes but doesn't it seem necessary to know whether a model is valid or not with the server? Like... If I had a command that created objects, I would want to know if models are valid within the script to know whether or not the players should be able to create the model they requested.
What do you mean by valid? If you mean what I think you do, you could use an array:

Code:
#define MAX_CUSTOM_MODEL_SLOTS 29001 // -1000 to -30000
#define CUSTOM_MODEL_OFFSET_FROM_ZERO 1000

new bool:iscmodelvalid[MAX_CUSTOM_MODEL_SLOTS];

public OnGameModeInit()
{
    AddSimpleModel(0, 10000, -1001, "name1.dff", "name1.txd");
    iscmodelvalid[-1001 + MAX_CUSTOM_MODEL_SLOTS + CUSTOM_MODEL_OFFSET_FROM_ZERO] = true;

    AddSimpleModel(0, 10000, -30000, "name2.dff", "name2.txd");
    iscmodelvalid[-30000 + MAX_CUSTOM_MODEL_SLOTS + CUSTOM_MODEL_OFFSET_FROM_ZERO] = true;
}

IsValidCustomObjectModel(modelid)
{
    if (modelid < -30000 || modelid > -1000) return false;
    return iscmodelvalid[modelid  + MAX_CUSTOM_MODEL_SLOTS + CUSTOM_MODEL_OFFSET_FROM_ZERO];
}



Re: Validating models - Crayder - 04.12.2017

Yeah and what about if they are added with artconfig.txt? We would need a native function to see if the model is added. That's the only way unless someone hooked up a plugin to detect the models added.