SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 28/04/2020, 03:38 PM   #1
Android98
Little Clucker
 
Join Date: Apr 2020
Location: Paraguay
Posts: 14
Reputation: 0
Default Simple way to get modelid from a pickup

This is my first tutorial, I was a pawn scripter about 4 years ago, and now (because of this quarantine) I'm coming back scripting, so now I'll show you a simple way to get the "modelid" from a pickup. This can be usefull if, for example, you want to get a weapon picking up a specific model of pickup. So let's get into this:

Step 1: Is not necesary to do this with all your pickups, but if you want to get the modelid from a specific pickup, you have to do this function:
Code:
stock AddPickup(modelid,type,Float:X,Float:Y,Float:Z,virtualworld=0)//You can name this however you want
{
	new m[6],pickupid;
	pickupid = CreatePickup(modelid,type,X,Y,Z,virtualworld);
	format(m,sizeof(m),"m%d",pickupid);//This is important, we're save the modelid for each pickupid we create using this function
	SetSVarInt(m,modelid);//Saving modelid
	return pickupid;
}
Step 2: Now we're going to create the function that gets the modelid:
Code:
stock GetPickupModel(pickupid)
{
	new s[6];
	format(s,sizeof(s),"m%d",pickupid);
	return GetSVarInt(s);//We just return the modelid by this simple way
}
Final step: When you're going to delete this kind of pickups, you have to do it by this function:
Code:
stock DestroyPickupEx(pickupid)
{
        new s[6];
	format(s,sizeof(s),"m%d",pickupid);
	DeleteSVar(s);
	return DestroyPickup(pickupid);
}
__________________
Have you ever imagine a Roleplay and DeathMatch server in one? I guess it would be a perfect life simulator, isn't it? Well, you'll find out...

3/10
Android98 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
[FilterScript] Simple rob casino pickup [FS] JohnnyIV Filterscripts 22 17/01/2014 06:24 AM
[Tutorial] How To Make A Simple Pickup JustinAn Tutorials 5 13/12/2012 01:13 AM
Simple Pickup [Help] kbalor Scripting Help 3 06/09/2012 12:10 PM
[Tutorial] Simple Pickup Mento Tutorials 18 10/06/2012 02:07 AM
simple question in for pickup code Sfinx_17 Help Archive 4 23/08/2009 04:16 PM


All times are GMT. The time now is 08:02 PM.


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