I'm needing help with something I'm scripting
#1

Hey guys, well I don't know if I do it the nooby way or not but, when adding vehicles to my server (Ones not in the vehicle list that comes with the samp server files) I tend to do /save and then copy the vehicle save to my script and add it in so I can add custom vehicles... Theres a few problems with that, first it only adds AddStaticVehicle instead of AddStaticVehicleEx which is what I prefer to use....

I tried numerous amounts of vehicle plotter programs to do with SAMP but I do not like them. So I decided to script my own filterscript that does the same as /save but it adds the AddStaticVehicleEx as apposed to AddStaticVehicle, it also adds the respawn timer to what I want it to be... Problem is. When I came to testing it, everything worked and it came out perfectly apart from at the end of every AddStaticVehicleEx it adds = 0; Let me show you an example.

pawn Код:
AddStaticVehicleEx(411, 2324.415771, 2408.037597, 10.471055, 91.636222, -1, -1, 1000);=0
AddStaticVehicleEx(485, 2322.960937, 2415.904052, 10.338153, 89.936119, -1, -1, 1000);=0
Any idea's on how to get rid of the =0 I use dini btw. Once this if fixed, if anyone wants the filterscript give me a shout and I'll upload it to ya
Reply
#2

I suggest you use the default writing functions.
https://sampwiki.blast.hk/wiki/Fwrite
Reply
#3

hm. to get rid of the "=0" at the lines end, search for your formatting line, it could look like this:
Код:
format(string,sizeof(string),"AddStaticVehicleEx(%d, %f, %f, %f, %f, %d, %d, %d);=0",VehID,blablabla
.. and just remove the =0 from the "innerside of the string=0".
Reply
#4

pawn Код:
format(saver, sizeof(saver), "AddStaticVehicleEx(%i, %f, %f, %f, %f, -1, -1, 1000);", carid, xpos, ypos, zpos, faceangle);
Thats my code for the format, = 0 is not there as you can see. Any other suggestions?
Reply
#5

then goto line 0, and search for the string "=0" through the entire code. since its a filterscript, it wont find that many results. oh, DINI uses the "=" for defining values (like Admin=5), so searching for each "DINI_" line will do a better job. comment some lines out which re-format your saver string, it cant be that hard to spot that bug.
edit: as Wesley221 suggested: stick to the native file functions, you can depend on their efficience.
Reply
#6

Like i said, use the default writing functions.
pawn Код:
stock SaveVehicle(modelid, Float:x, Float:y, Float:z, Float:a, comment[])
{
    new File:Log = fopen( "PathToFolder/Name.txt", io_append), logData[128];
    format( logData, sizeof logData, "AddStaticVehicle(%i, %0.4f, %0.4f, %0.4f, %0.4f, -1, -1, 1000); // %s \r\n ", modelid, Float:x, Float:y, Float:z, Float:a, comment );
    fwrite( Log, logData );
    fclose( Log );
    return 1;
}
Thats just an quick example, didnt test it, should work.
Reply
#7

Ok that fixed it but can I ask what the %0.4f does?

What is the 0.4f for?
Reply
#8

Shows a float to 4 decimal points.
Reply
#9

Like calgon said, it stops after 4 decimal numbers.
Normally when you get a position, it will give you about 6/8 decimal numbers, and with this it will only go to the first 4 decimals.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)