.map reader (not loader)
#1

Hi all,

is there a way to read .map files and spawn the player with the coordinates in the .map file ?

EDIT:

I've currently this stock
Reply
#2

Open the .map file and find a way to retrieve the coordinates you need. Sscanf should help you with that.
Reply
#3

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Open the .map file and find a way to retrieve the coordinates you need. Sscanf should help you with that.
Yes i see, it's quite difficult ... I have this already:

pawn Код:
stock SpawnPlayerInMap(playerid)
{
    new mapName[32],path[64], line[256];
    format(path, sizeof(path), "/maps/%s.map", mapname);
   
    if(!fexist(path)){
    format(string, sizeof(string), "Unable to locate map %s!", mapname);
    print(string);
   
    while(fread(map,line))
    {

    }
//<vehicle id="vehicle (Rancher) (1)" paintjob="0" model="489" plate="NRHLSGL" interior="0" dimension="0" name="" posX="-85.281013" posY="1339.174316" posZ="13.297609" rotX="" rotY="" rotZ="" />
}
I dunno how to use sscanf then ...
Reply
#4

http://forum.sa-mp.com/showpost.php?...1&postcount=12
Reply
#5

Hmm thanks, but is this gonna work with vehicles too ?

pawn Код:
while(fread(map,line,sizeof(line)))
    {
        if(sscanf(line, "p<\">'posX:'f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f'model='d",x,y,z,rx,ry,rz,vehmodel));
        PutPlayerInVehicle(playerid,vehmodel,0);
    }
Reply
#6

Well, it doesn't separate objects and vehicles at all, because I made it only for objects, so you have to modify it a little bit to get it working.

Also, you have to create the vehicle before you can put the player in it.

I don't know if this works, but I am here to help fix it if it doesn't:
pawn Код:
while(fread(file, string, sizeof(string)))
{
    if(sscanf(string, "p<\">'vehicle id='s'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f'model='d", string, x, y, z, rx, ry, rz, model))
    {
        continue;
    }

    vehicleid = CreateVehicle(model, x, y, z, rz, 1, 1, 60);
    PutPlayerInVehicle(playerid, vehicleid, 0);
}
Currently it's fucked up, because it will create all the vehicles in the .map and put the same player in each one.
Reply
#7

Quote:
Originally Posted by Finn
Посмотреть сообщение
Well, it doesn't separate objects and vehicles at all, because I made it only for objects, so you have to modify it a little bit to get it working.

Also, you have to create the vehicle before you can put the player in it.

I don't know if this works, but I am here to help fix it if it doesn't:
pawn Код:
while(fread(file, string, sizeof(string)))
{
    if(sscanf(string, "p<\">'vehicle id='s'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f'model='d", string, x, y, z, rx, ry, rz, model))
    {
        continue;
    }

    vehicleid = CreateVehicle(model, x, y, z, rz, 1, 1, 60);
    PutPlayerInVehicle(playerid, vehicleid, 0);
}
Currently it's fucked up, because it will create all the vehicles in the .map and put the same player in each one.
yes true, i must use random also. I first want to test without random but i have an error. And i can't find the fix.

Код:
C:\Users\Michael2\Downloads\GTA\Destruction Derby 0.3d\filterscripts\Test.pwn(177) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
line 177=
pawn Код:
while(fread(mapname,line,sizeof(line)))
//and i have these:

new line[256];

// + edited the stock so ..

stock SpawnPlayerInMap(playerid,mapname[])
Reply
#8

By map reader u want to know that how u can see the lines that r written in the .map file like Object(....)??
If yes then u can open it with Notepad
Reply
#9

He want to load .map files on the server, not to see .map file content
Reply
#10

You have to open the file with fopen before you can read it.
pawn Код:
native File:fopen(const name[], filemode: mode = io_readwrite);
Like you can see here, the first parameter in fread is the file handle, not a string.
pawn Код:
native fread(File: handle, string[], size = sizeof string, bool: pack = false);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)