19.05.2012, 20:32
Use the samp map editor to convert the CreateObject code to just raw data.
Example:
That is a VERY rough example, it was just to give you the idea.
Example:
pawn Код:
CMD:loadmap(playerid, params[])
{
new
mapname[60], // a new string for the mapname
string[128] // the string that will be formatted as the path
;
if(sscanf(params, "s[60]", mapname)) // if they didn't type a name
{
// then it sends this message
SendClientMessage(playerid, -1, "USAGE: /loadmap [mapname]");
return 1;
}
// if they did type a name then it formats the name with '.txt'
format(string, 128, "%s.txt", mapname);
// if the file does not exist
if(!fexist(string))
{
// then it returns this message
return SendClientMessage(playerid, -1, "Invalid Map Path");
}
new
File:map = fopen(string, io_read), // open the file for reading
// we then define new variables for the object info.
model,
f:x,
f:y,
f:z,
f:rotX,
f:rotY,
f:rotZ,
f:drawdistance,
szObject[150], // the string to store the file lines in
objectcount = 0 // the count for the objects
;
// while there is text in the line, we read the line, and store the line into the szObject string
while(fread(map, szObject))
{
// using sscanf, we split the line into the object paramters and if the line does
// not follow this format ...
if(sscanf(szObject, "dfffffff", model, x, y, z, rotX, rotY, rotZ, drawdistance))
{
// then we print the formatted print on the console
printf("Invalid Line Format At File: %s", string);
// and then skip the loop iteration
continue;
}
// we split the line into the object format
sscanf(szObject, "dfffffff", model, x, y, z, rotX, rotY, rotZ, drawdistance);
// then we create the object
CreateObject(model, x, y, z, rotX, rotY, rotZ, drawdistance);
// and the object count goes up
objectcount++;
}
printf("%d objects loaded from file: %s", objectcount, string);
fclose(map); // we then close the file
return 1;
}