Load and read username.ini -
Biesmen - 08.11.2010
The topic starts here: http://forum.sa-mp.com/showpost.php?...3&postcount=22
(
https://sampforum.blast.hk/showthread.php?tid=188728&page=3 number 22)
Re: Check file of an other username -
Biesmen - 09.11.2010
Hm, I tried something like get the player name of a person if you type the ID.
But ofcourse that didn't work out.
Re: Check file of an other username -
Biesmen - 09.11.2010
Doesn't it work like an /admins command? It will have to look through ALL user files to find the adminlevel of the players. I think it's fine to use it this way.
Re: Check file of an other username -
Hiddos - 09.11.2010
Quote:
Originally Posted by Biesmen
Doesn't it work like an /admins command? It will have to look through ALL user files to find the adminlevel of the players. I think it's fine to use it this way.
|
The base principe of /admins compared to this is the same, however very, very, very unefficient. I'd suggest creating an extra var for each (ownable) vehicle to store the name in.
Re: Check file of an other username -
Biesmen - 09.11.2010
I don't really understand what you mean, it should work this way. It'll spawn more than one vehicle if people own the car.
Re: Check file of an other username -
Mike_Peterson - 09.11.2010
offtopic: Biesmen, didnt you play at Argonath RPG?
ontopic: If you make a .ini for the car owners then you can do Dini_Get
just make it where the person buys a car... though if ur server is populated already you will have to reset everyones car i thought..
Re: Check file of an other username -
Biesmen - 10.11.2010
Quote:
Originally Posted by Mike_Peterson
offtopic: Biesmen, didnt you play at Argonath RPG?
|
Yes. I still play there.
Quote:
Originally Posted by Mike_Peterson
ontopic: If you make a .ini for the car owners then you can do Dini_Get
just make it where the person buys a car... though if ur server is populated already you will have to reset everyones car i thought..
|
That's not what I mean. But thank you for trying
It's supposed to check for the owner name. But I'll edit my system. I think I'll make one file(as stated above), which includes all the information to spawn a car and a string which tells you who the owner is. I think it will be a lot easier that way. But I still prefer the method I currently use.
edit: No, I'm not gonna use one file. It'll be a lot more work to change the, for example, x,y,z coordinates for your car.
Re: Check file of an other username -
Biesmen - 10.11.2010
Quote:
Originally Posted by ******
Trust me, using many files and searching through them all will put HUGE strain on your server and is likely to introduce noticeable lag in your server, which will drastically reduce players' experiences.
|
Okay, I'll try to use your way.
But I'm quite new to something like that, so it'll take a time for me to add new lines in one file by a command.
Edit: But how do I make it spawn when the player logs on. This is one of the main reasons I used seperated files.
Something like..
Код:
GetPlayerName(playerid, carowner, sizeof(carowner));
new File:ownvehicles=fopen("vehicles.ini", io_read);
new idx;
while(fread(ownvehicles, string)){
idx = 0
carid = strval(strtok(string,idx));
carowner = strtok(string,idx);
modelid = strval(strtok(string,idx));
carX = floatstr(strtok(string,idx));
carY = floatstr(strtok(string,idx));
carZ = floatstr(strtok(string,idx));
carRot = floatstr(strtok(string,idx));
pC1 = strval(strtok(string,idx));
sC2 = strval(strtok(string,idx));
if(logged[carowner] == 1) {
vehicle[carid] = CreateVehicle(modelid, X, Y, Z, carRot, pC1, sC2, 0);
return 1;
}
}
vehicles.ini:
Quote:
12 Biesmen 420 1780.105 -1860.396 13.271 269.02 -1 -1
|
the logged[playerid]/[carowner] thing, is my system. So don't worry about that
Re: Check file of an other username -
SuperS82 - 10.11.2010
Most Car Sysytems have a cars.ini file or something... In that file is a set of variables... example CarID,CarX,CarY,CarZ,CarAngle,Col1,Col2,Owner(Play ername)... thats what you need
Re: Check file of an other username -
Biesmen - 10.11.2010
SuperS, if you read my previous post you wouldn't be posting this as I already have that.
Re: Check file of an other username -
SuperS82 - 10.11.2010
All that extra information wasnt on the post till you edited it...
Re: Check file of an other username -
kacperoo - 11.11.2010
What about using mysql/sqlite?
Re: Check file of an other username -
Biesmen - 11.11.2010
Quote:
Originally Posted by Y_Less
I would store all the data on the cars, including the owner, in a single file, then have a reference to which car a player owns in their user file too.
|
...........
Quote:
Originally Posted by Biesmen
Okay, I'll try to use your way.
But I'm quite new to something like that, so it'll take a time for me to add new lines in one file by a command.
Edit: But how do I make it spawn when the player logs on. This is one of the main reasons I used seperated files.
Something like..
Код:
GetPlayerName(playerid, carowner, sizeof(carowner));
new File:ownvehicles=fopen("vehicles.ini", io_read);
new idx;
while(fread(ownvehicles, string)){
idx = 0
carid = strval(strtok(string,idx));
carowner = strtok(string,idx);
modelid = strval(strtok(string,idx));
carX = floatstr(strtok(string,idx));
carY = floatstr(strtok(string,idx));
carZ = floatstr(strtok(string,idx));
carRot = floatstr(strtok(string,idx));
pC1 = strval(strtok(string,idx));
sC2 = strval(strtok(string,idx));
if(logged[carowner] == 1) {
vehicle[carid] = CreateVehicle(modelid, X, Y, Z, carRot, pC1, sC2, 0);
return 1;
}
}
vehicles.ini:
Код:
12 Biesmen 420 1780.105 -1860.396 13.271 269.02 -1 -1
the logged[playerid]/[carowner] thing, is my system. So don't worry about that
|
Re: Check file of an other username -
TheXIII - 11.11.2010
I would do it like this:
Quote:
users\biesmen.ini
CarID = 12 /// UNIQUE ID, not vehicleID.
whatever...
|
Quote:
cars\car12.ini
Owner = biesmen
X-Y-Z-ANGLE-etc.
...
|
Now, when user logs on, you know from the user file, that this users unique car ID is 12. So you load car12.ini into server.
Also, you should create a enum/array, like.. Car[CarID][VehicleID].. so you can easily get the vehicleid of players car. Doing it the other way around is useful too - vehicles[vehicleid][CarID]. So you can easily find the unique CarID, and the owner of the vehicle, with just vehicleid, without having to have any loop.
Using SQL would make it easier.. kinda. As it has auto increment/unique id aleady in it. But if you don't have experience with it, it could be hard to get your head around it.
Sorry if I explained it badly.
Re: Check file of an other username -
TheXIII - 11.11.2010
Err... list all vehicles? I thought he just wanted so when you sit in a vehicle it says "
Vehicle ID: n, Owner: X".
Re: Check file of an other username -
Biesmen - 12.11.2010
So, should I use the way I posted as latest? And is it well coded?
Re: Check file of an other username -
Biesmen - 18.11.2010
Edit:
Ignore my previous code.
I am using a new code now. Which will load seperate files of a player. It seems to read the file and spawn the car, but I can't make it compare the owner's name with the user's name, if you get what I mean.
I want it to send you a message if you enter your OWN car.
I am currently using this code:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{ new pname[255];
for(new i; i < sizeof(COwnerData); i++)
{
if(COwnerData[i][CarOwner] == GetPlayerName(playerid, pname, sizeof(pname))) {
SendClientMessage(playerid, COLOR_WHITE, "You entered your own car.");
}
}
It doesn't work. So basically I want it to check if you're the owner of that car. It doesn't give errors, it compiles successfully.
I hope you can help me.