SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 11/08/2019, 01:17 PM   #1
MafiaOink
Big Clucker
 
MafiaOink's Avatar
 
Join Date: Jun 2014
Location: Pakistan
Posts: 187
Reputation: 28
Post How to add custom models without RESTART (The base)

So you have seen some servers like LSRP add models ingame without restart? It's not a miracle. I thought at first it was using Pawn.Raknet and sending ModelData and ModelFile RPC's but I found we cannot calculate the RPC using some SAMP function as there is none for it. Turns out, all you have to do is:

AddCharModel OR AddSimpleModel
and then SetPlayerVirtualWorld.

Now, basically what you could do is add all the char models or from a array / using a command. And once all are done, you can setallplayer's virtual world to 999 then back to where they were under onplayerfinisheddownloading.

I'm not going to make a detailed tutorial for this because I only wanted to share this piece of information, sorry if the prefix is misguiding but I did give you the idea.


Here's some sample code:
Code:
new g_ModelsAwaiting = 0;
new p_OldWorld[MAX_PLAYERS] = { 0 };

CMD:addskin(playerid, params[])
{
	new 
		skinID, 
		baseID, 
		skinName[32];
		
	if(sscanf(params, "dds[32]", skinID, baseID, skinName)) return SendClientMessage(playerid, 0xFF0000FF, "/addskin [skinID e.g. 20001] [baseID e.g. 299] [skin name, e.g. wmori]");
	
	new 
		txd[32 + 4], 
		dff[32 + 4];
		
	format(txd, sizeof txd, "%s.txd", skinName);
	format(dff, sizeof dff, "%s.dff", skinName);
	
	if(AddCharModel(baseID, skinID, dff, txd))
	{
		g_ModelsAwaiting++;
		SendClientMessage(playerid, 0x00FF33FF, "Done! To reload all models, type /reloadmodels to have them all downloaded.");
	}
	else SendClientMessage(playerid, 0xFF0000FF, "Failed! Make sure you did not include .dff or .txd in name and the files are present.");
	
	return 1;
}

public OnPlayerFinishedDownloading(playerid, virtualworld)
{
    if(p_OldWorld[playerid] != 0 && virtualworld == 420)
	{
		SetPlayerVirtualWorld(playerid, p_OldWorld[playerid]);
		p_OldWorld[playerid] = 0;
	}
    return 1;
}

CMD:reloadmodels(playerid)
{
	if(!g_ModelsAwaiting) return SendClientMessage(playerid, 0xFF0000FF, "No models are awaiting reload.");
	
	for(new p = 0, m = GetPlayerPoolSize(); p <= m; p++)
	{
		p_OldWorld[p] = GetPlayerVirtualWorld(p);
		SetPlayerVirtualWorld(p, 420);
	}
	SendClientMessageToAll(0x00FF33FF, "An administrator has reloaded all the models.");
	return 1;
}
Obviously this isn't foolproof, I just gave an example.

Credits: Me (KevY)
__________________
MafiaOink is offline   Reply With Quote
Old 11/08/2019, 01:19 PM   #2
Marko43
Little Clucker
 
Marko43's Avatar
 
Join Date: Jul 2018
Posts: 9
Reputation: 0
Default Re: How to add custom models without RESTART (The base)

+rep
__________________
Marko43 is offline   Reply With Quote
Old 11/08/2019, 01:22 PM   #3
MafiaOink
Big Clucker
 
MafiaOink's Avatar
 
Join Date: Jun 2014
Location: Pakistan
Posts: 187
Reputation: 28
Default Re: How to add custom models without RESTART (The base)

Oh and one more thing, after server restart or full restart actually,m the added models will be gone. So as a backup plan, you can make a sql with saved dynamic models etc and iterate and add them in under ongamemodeinit as we can't modify artwork.txt inside modelfolder. OR you can chbange artpath in samp server config to be in scriptfies.
__________________
MafiaOink is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom models - download Oficer SA-MP 0.3.DL 3 22/03/2019 11:12 AM
Custom models andrey1311 General 8 24/03/2018 10:44 AM
[Tutorial] Using custom models S4t3K Tutorials 18 17/03/2018 11:57 AM
Why Custom Models not in SA-MP maxisaibot Discussion 5 07/05/2014 05:26 PM
Custom Models Trooper[Y] Help Archive 16 29/11/2010 06:19 AM


All times are GMT. The time now is 11:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.