SA-MP Forums Archive
.map reader (not loader) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: .map reader (not loader) (/showthread.php?tid=303003)



.map reader (not loader) - Michael@Belgium - 11.12.2011

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


Re: .map reader (not loader) - Hiddos - 11.12.2011

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


Re: .map reader (not loader) - Michael@Belgium - 11.12.2011

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 ...


Re: .map reader (not loader) - Finn - 11.12.2011

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


Re: .map reader (not loader) - Michael@Belgium - 11.12.2011

Quote:
Originally Posted by Finn
Посмотреть сообщение
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);
    }



Re: .map reader (not loader) - Finn - 11.12.2011

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.


Re: .map reader (not loader) - Michael@Belgium - 11.12.2011

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[])



Re: .map reader (not loader) - §с†¶e®РµРe - 11.12.2011

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


Re: .map reader (not loader) - array13 - 11.12.2011

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


Re: .map reader (not loader) - Finn - 11.12.2011

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);