Hello There, Guest! Login or Register


How to run MTA objects with SA-MP
#1
Hai dear LVP Mappers,

Here i'll try to explain how to run MTA objects in SAMP (by .pwn file), and will give you some useful commands for map testing step by step:

1:RUN MTA OBJECTS WITH SAMP


STEP 1: Convert your objects to SAMP pwn file

First, save your current map from MTA Map editor then quit. Goto ..\ MTA San Andreas\mods\map_editor\maps and open your file with notepad, copy them all, and goto http://www.convertffs.com/ and put there your codes. Choose input/output, and press convert. It will give you .pwn codes of your map. Copy or keep them, we will use them at next steps.

STEP 2: Download samp server files and open .pwn files

Goto http://www.sa-mp.com/download.php or http://files.sa-mp.com/samp03asvr_R8_win32.zip (to direct download) to download samp server files. After downloading finish, unzip them to a folder. then goto (your folder name)\pawno and open pawno.exe (Warning: If you use vista/w7, open it as administrator and untick options> associate with .pwn files.).  Press "New", then it will give you lots of codes.

STEP 3: Put your codes into .pwn file

Now, we need our converted codes which will be pasted to OnGameModeInIt public. Copy them and paste them into OnGameModeInIt. Example:

Code:
public OnGameModeInit()
{

CreateObject(902,2479.05615200,-1657.44152800,12.26043700,0.00000000,0.00000000,0.00000000); //object
CreateObject(902,2478.99462900,-1660.63818400,12.27651100,0.00000000,0.00000000,0.00000000); //object(1)
CreateObject(902,2480.73950200,-1664.45031700,12.26916500,0.00000000,0.00000000,0.00000000); //object(2)
CreateObject(902,2482.63110400,-1665.00671400,12.27424500,0.00000000,0.00000000,0.00000000); //object(3)
CreateObject(902,2474.04663100,-1670.46325700,12.26725500,0.00000000,0.00000000,0.00000000); //object(4)
CreateObject(902,2604.61352500,-1682.91491700,-45.96632800,0.00000000,0.00000000,0.00000000); //object(5)
CreateObject(902,2447.38110400,-1642.51599100,15.18253800,0.00000000,0.00000000,0.00000000); //object(6)
CreateObject(902,2479.19531300,-1656.03491200,12.26116700,0.00000000,0.00000000,0.00000000); //object(7)
CreateObject(902,2482.54907200,-1655.60498000,12.25780700,0.00000000,0.00000000,0.00000000); //object(8)
CreateObject(902,2488.11669900,-1656.25354000,12.29017100,0.00000000,0.00000000,0.00000000); //object(9)
CreateObject(902,2490.12280300,-1658.11181600,12.26870900,0.00000000,0.00000000,0.00000000); //object(10)
CreateObject(902,2490.77539100,-1661.30749500,12.26870800,0.00000000,0.00000000,0.00000000); //object(11)
CreateObject(902,2489.80639600,-1665.08264200,12.27651100,0.00000000,0.00000000,0.00000000); //object(12)
CreateObject(902,2489.42211900,-1666.05456500,12.27651100,0.00000000,0.00000000,0.00000000); //object(13)
CreateObject(902,2500.73950200,-1659.01733400,12.30006200,0.00000000,0.00000000,0.00000000); //object(15)
CreateObject(902,2494.27270500,-1655.80102500,12.29370700,0.00000000,0.00000000,0.00000000); //object(16)

return 1; // Don't delete or change this one.
}

Warning: You must put them between two parentheses and before "return 1;", as my example.

Here we set them for samp. Save them into "gamemodes" folder then exit from it. If you wish, press "Complie" button (which is taking part upper of window, blue triangle) to provide accuracy of codes. If there is a problem, it will show you as errors, if isnt, it will say you sometnig like "Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase" only.

STEP 4: Get your server started

We need to open "server.cfg" file with notepad. You will see lots of things again, like rcon pass, gamemodes, filterscripts... All you need, write your name of saved .pwn file near of "gamemodes", as my example:

Code:
echo Executing Server Config...
lanmode 0
rcon_password LRftw
maxplayers 50
port 7777
hostname LVP Mapping Team Object Testing Server
gamemode0 objectpwnfile
filterscripts
announce 0
query 1
weburl [url=http://www.sa-mp.nl]www.sa-mp.nl[/url]
maxnpc 0
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000

I wrote there "objectpwnfile" as gamemode name, but you will write there yours name. Save it and close.

Time to start server. Open your "samp-server.exe", and keep it running. Server will be running till u shut samp-server.exe down. Open your samp.exe and add your own server ip:

127.0.0.1:7777

Then join your server and test your objects  :Y)

2:SOME USEFUL TUTORIALS


Add a teleport command to start point: Its not neccessary, but if you want to go there easily, use this one. First, you will need a spawnpoint which made in MTA Map Editor (start point). If you save it in a vehicle, you can find your spawnpoint easly (because all of will appear as createobject, and only 1 will appear as AddStaticVehicle).

[b]If it is as AddStaticVehicle:


AddStaticVehicle(modelid,float:x,float:y,float:z,float:angle,color1,color2);

If it is as CreateObject:

CreateObject(modelid,float:x,float:y,float:z,float:rx,float:ry,float:rz);

We will need "x","y","z" codes. You will put them into OnPlayerCommandText as "SetPlayerPos", like my example:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/teleport", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid,float:x,float:y,float:z); // like SetPlayerPos(playerid,1121.0,1131.0,12.0); as you see, we have 3 coordinates (x,y,z).
        SendClientMessage(playerid,0x038200FF,"You have teleported to start point, have fun.");
        return 1;
    }
    return 0;
}

I put "x","y","z" posses AddStaticVehicle to SetPlayerPos only, that's all. You will type /teleport in-game, then it will tp you to startpoint.

Give yourself a car: Its not neccessary like teleporting, too but you will be able to give urself a car if you do this one. Look at example and do whatever i did there:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/givemecar", cmdtext, true, 10) == 0)
    {
            DestroyVehicle(Vehicle[playerid]);
            GetPlayerPos(playerid,X,Y,Z);
            Vehicle[playerid]=CreateVehicle(411, X, Y, Z, -1, -1, -1 ,-1); // it will give you an infernus
            SendClientMessage(playerid,0x038200FF,"Now you have an Infernus, have fun!");

        return 1;
    }
    
    if (strcmp("/givemebike", cmdtext, true, 11) == 0)
    {
            DestroyVehicle(Vehicle[playerid]);
            GetPlayerPos(playerid,X,Y,Z);
            Vehicle[playerid]=CreateVehicle(522, X, Y, Z, -1, -1, -1 ,-1); // it will give you a NRG-500
            SendClientMessage(playerid,0x038200FF,"Now you have an NRG-500, have fun!");

        return 1;
    }
    return 0;
}

Also, you can give yourself a random vehicle with using "-1" (change "522" to "-1"). Or:

http://wiki.sa-mp.com/wiki/Category:Vehicle

Choose which vehicle you want, and write its id as vehicle id (change "522" to your vehicle id).

copy/paste to upper of page (under #include <a_samp>):

Code:
#pragma tabsize 0

new Vehicle[MAX_PLAYERS];
new Float:X, Float:Y, Float:Z;

Here, i coded a NRG and Infernus spawner command.

[b]Moving Objects: Lot's of one of you were asking about this one. And now, ill try to explain how to move objects in SAMP format:

[b]First;
we need two objects which is including top and bottom points of moving orbit. It will move along these two object orbit( up up up, then stop for a bit, down down down, then stop for a bit, up up up..).

As like this pic:

[Image: 5mbb0g.jpg]

Warning: I made two objects to show highes and lowest points of elevator. U will need to delete one of this objects after u got poses.

Now, we will use x,y,z posses again. For example, it will be like an elevator (up and down only), we will change Z pos which means height float of game.

We will create an object, and will move it by MoveObject command. Ill try to explain with an example:

Code:
// to upper of script, copy/paste this:

new Object1; //introducing objects to pwn file via this word

forward Object1Down(); //introducing publics to pwn file
forward Object1Up();

//to OnGameModeInIt (top of gamemodeinit, between parentheses):

public OnGameModeInit()
{

SetTimer("Object1Up",1000,0); // here, we will set the first timer for moving object ( Settimer("PublicName",Miliseconds,0 or 1); >> 1000 means 1 seconds, 60000 means 1 mins; 1 means timer will repeat, 0 means wont repeat. We will prefer 0 here.

Object1=CreateObject(2669,181.298,-3835.451,7.191,0.0,0.0,270.000); // here, we aqualized object with a word (Object1). That's the object which was made to bottom, and "object1up" timer will get it moved up.

return 1;
}

//To bottom of script:

public Object1Down() //that's used for what will happen at finish of timer.
{
StopObject(Object1); //stops the object first,
MoveObject(Object1,181.298,-3835.451,7.191,2.00); //gets it moving again (down)
SetTimer("Object1Up",20000,0); //sets "up" timer for 20 secs, means "objectdown" public will finish in 20 secs, "objectup" one will start in 20 secs.
}

public Object1Up()
{
StopObject(Object1); //stops the object first,
MoveObject(Object1,181.278,-3835.425,62.364,2.00); //gets it moving again (up) >> MoveObject(object word/id,to x pos,to y pos,to z pos, speed (2.0 is ok, or 3.0));
SetTimer("Object1Down",20000,0); //see, it activates down timer in 20 secs to provide loop of moving (you need to set it for distance, if you set it high, it will stop and start to moving again too late, if u set it low, object can't be able to go to reach points, will change direction). Via this timers, object will keep movin, wont stop.
}

It is mixed a bit, but if you read and try carefully, u'll see, it will work  :Y)

___________________________________________________________________________________________

If you have questions, feel free to ask!

Have fun & Good luck

LR  :+
Reply
#2
Great tut, might be helpful for some people :). Thanks LR!

Edit: stickied
Reply
#3
hope so, np  :+
Reply
#4
Very helpful tutorial!
Reply
#5
MoveObject tutorial has been added. Hope, it might help u    :+

LR
Reply
#6
Awesome moveobject tutorial,thx!  :9~
Reply