Major problem with rp script i made
#1

Ok well ive atempted to make an rp script and the way i store all my player information is in a Dini

The information is stored into the dini fine and worked fine until i realised something.
Firstly this is how the dini is created its created inside scriptfiles\Players and then inside that is the dini that is named as the players ingame name and inside that is all the player statistics.

To help you understand whats happening i will create a senario.


2 players are in the server
1 has a drivers license, the other one doesnt
( in the dini its driverslicense = 0 if they dont have a lisence and 1 if they do)
the player who has their drivers license attempts to get into a car and is instantly kicked out because it says he doesnt have a license but he does.

For some reason the information between the 2 user accounts is intersecting with each other. As you can imagine this will cause chaos within my whole script. We have tried using enums and they still intersect with each other.

Quote:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 67 && response == 1)//login
{
new tmp = dini_Int(User[playerid][pFile], "HPassword");
if(!strlen(inputtext[0])) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: /login [password]");
if(!dini_Exists(User[playerid][pFile])) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: You are not registered!");
if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: You are already logged in!");

if(udb_hash(inputtext[0]) != tmp)
{
format(String, 256, "You specified the wrong password for %s!You are being Kicked.", User[playerid][pName]);
SendClientMessage(playerid, COLOR_RED, String);
Kick(playerid);
}
else
{
logged[playerid] = 1;
format(String, sizeof(String), "Welcome~n~~r~%s",User[playerid][pName]);
GameTextForPlayer(playerid, String, 6000, 1);
User[playerid][pAdminLevel] = dini_Int(User[playerid][pFile], "AdminLevel");
User[playerid][px] = dini_Float(User[playerid][pFile], "z");
User[playerid][py] = dini_Float(User[playerid][pFile], "y");
User[playerid][pz] = dini_Float(User[playerid][pFile], "z");
User[playerid][pLicense] = dini_Int(User[playerid][pFile], "License");
User[playerid][pScore] = dini_Int(User[playerid][pFile], "Score");
User[playerid][pMoney] = dini_Int(User[playerid][pFile], "Money");
SetPlayerScore(playerid, User[playerid][pScore]);
new lebel = User[playerid][pAdminLevel];
SetPlayerPos(playerid,User[playerid][px],User[playerid][py],User[playerid][pz]);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,User[playerid][pMoney]);
AllowTele[playerid]=1;
format(String, 256, "[SYSTEM]: Successfully logged in! (level: %d)!", lebel);
SendClientMessage(playerid,COLOR_RED, String);
printf("%s (%i) logged in with password %s", User[playerid][pName], playerid, inputtext[0]);
}
return 1;
}
if(dialogid == 70 && response == 1)//register
{
if(!strlen(inputtext[0])) SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: /register [password]");
if(dini_Exists(User[playerid][pFile])) SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: You are already registered!");
else
{
dini_Create (User[playerid][pFile]);
dini_IntSet (User[playerid][pFile], "HPassword", udb_hash(inputtext[0]));
dini_Set (User[playerid][pFile], "Password", inputtext[0]);
dini_IntSet (User[playerid][pFile], "Interior",0);
dini_IntSet (User[playerid][pFile], "AdminLevel",0);
dini_IntSet (User[playerid][pFile], "Score", 0);
dini_IntSet (User[playerid][pFile], "License", 0);
dini_IntSet (User[playerid][pFile], "Money", 10000);
User[playerid][pAdminLevel] = dini_Int(User[playerid][pFile], "AdminLevel");
User[playerid][px] = dini_Float(User[playerid][pFile], "z");
User[playerid][py] = dini_Float(User[playerid][pFile], "y");
User[playerid][pz] = dini_Float(User[playerid][pFile], "z");
User[playerid][pLicense] = dini_Int(User[playerid][pFile], "License");
User[playerid][pScore] = dini_Int(User[playerid][pFile], "Score");
User[playerid][pMoney] = dini_Int(User[playerid][pFile], "Money");
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,User[playerid][pMoney]);
//dini_IntSet(file, "job1", 0);dini_IntSet(file, "job2", 0);dini_IntSet(file, "job3", 0);dini_IntSet(file, "job4", 0);
format(String, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s", User[playerid][pName], inputtext[0]);
SendClientMessage(playerid, COLOR_YELLOW, String);
logged[playerid] = 1;
SetPlayerPos(playerid, 1742.948242,-1860.797973,13.578297);
SendClientMessage(playerid, COLOR_YELLOW, "[SYSTEM]: You have been automatically logged in!");
}
return 1;
}
}

That is the dialog for registration and login Hope somebody knows how to fix my problem its really holding me back
Reply
#2

Maybe it will be fixed if you make 2 functions: 'RegisterPlayer(playerid)' and 'LoginPlayer(playerid)'
I used it for my script, and it worked (before it didn't, very strange)
Reply
#3

Here i will also include where it checks to see if they have a driving lisence
Quote:

public OnPlayerStateChange(playerid,newstate,oldstate)
{
new vehicle;
vehicle = GetPlayerVehicleID(playerid);
if(newstate==PLAYER_STATE_DRIVER)
{
if(User[playerid][pLicense]==0) RemovePlayerFromVehicle(playerid),SendClientMessag e(playerid, COLOR_RED, "You do not have a license to operate this vehicle, Book a driving test at the front desk of the DMV");
else if(User[playerid][pLicense]==3 && vehicle<=4) RemovePlayerFromVehicle(playerid),SendClientMessag e(playerid, COLOR_RED, "You are not authorized to drive this government vehicle");
else if(User[playerid][pLicense]==1 && vehicle<=4) SetPlayerRaceCheckpoint(playerid,0, 1556.22, -1838.86, 13.55, 1567.05, -1862.33, 13.38, 3.0);
else if(User[playerid][pLicense]==1 && vehicle>4) RemovePlayerFromVehicle(playerid),SendClientMessag e(playerid, COLOR_RED, "You do not have a license to operate this vehicle, Book a driving test at the front desk of the DMV");
}
else if(User[playerid][pLicense]==1 && vehicle<=4)
{
if(oldstate==PLAYER_STATE_DRIVER && newstate==PLAYER_STATE_ONFOOT)
{
User[playerid][pLicense]=0, DisablePlayerRaceCheckpoint(playerid);
SendClientMessage(playerid, COLOR_RED, "You have exited the test car, you have failed");
SendClientMessage(playerid, COLOR_RED, "To take the test again re-book at the front desk of the DMV");
}
}
return 1;
}

maybe that will help you think of something
Reply
#4

Can you explain what are you trying to do in OnPlayerStateChange ?
Reply
#5

Quote:

if(User[playerid][pLicense]==0) RemovePlayerFromVehicle(playerid),SendClientMessag e(playerid, COLOR_RED, "You do not have a license to operate this vehicle, Book a driving test at the front desk of the DMV");

that checks to see if there license = 0 if it does then it means they cannot drive the vehicle
Quote:

else if(User[playerid][pLicense]==3 && vehicle<=4) RemovePlayerFromVehicle(playerid),SendClientMessag e(playerid, COLOR_RED, "You are not authorized to drive this government vehicle");

License 3 means that they have their full license, so if they have their full license and try to get into a test car it removes them and says they are not authorised to drive a government vehicle.
Quote:

else if(User[playerid][pLicense]==1 && vehicle<=4) SetPlayerRaceCheckpoint(playerid,0, 1556.22, -1838.86, 13.55, 1567.05, -1862.33, 13.38, 3.0);

license = 1 is when the user has purchased a driving lesson, so when they have license one and the car is a test car it starts a checkpoint for their test.
Quote:

else if(User[playerid][pLicense]==1 && vehicle>4) RemovePlayerFromVehicle(playerid),SendClientMessag e(playerid, COLOR_RED, "You do not have a license to operate this vehicle, Book a driving test at the front desk of the DMV");

if your license = 1 (which only authorises u to drive the test car in a test) and u try to get in any other vehicle then you are removed and told
Quote:

"You do not have a license to operate this vehicle, Book a driving test at the front desk of the DMV")

Quote:

else if(User[playerid][pLicense]==1 && vehicle<=4)
{
if(oldstate==PLAYER_STATE_DRIVER && newstate==PLAYER_STATE_ONFOOT)
{
User[playerid][pLicense]=0, DisablePlayerRaceCheckpoint(playerid);
SendClientMessage(playerid, COLOR_RED, "You have exited the test car, you have failed");
SendClientMessage(playerid, COLOR_RED, "To take the test again re-book at the front desk of the DMV");
}
}

Basicly for this one if your license = 1 and your in a test car and you go from PLAYER_STATE_DRIVER to PLAYER_STATE_ONFOOT (AKA you get out of your car during the test) then the test is over it removes the checkpoints and you fail your test and have to rebook at the dmv again.
Reply
#6

Its not just with the drivers license but with all the player statistics for some reason when there are multiple people playing different players stats will interfere and cross with each other so essentially no players statistics are unique what i realy need to know is how to make it so that each players statistics are unique to them only and their files cannot be interfered with or crossed with another player.
Reply
#7

When do you set User[playerid][pFile] ?
Reply
#8

Quote:

#include <a_samp>
#include <Dini>
#include <colors>
#include <Dudb>
#include <Dutils>
#include <zcmd>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
enum pInfo
{
pAdminLevel,
pCash,
pScore,
pLevel,
pJob,
pCar,
pHouse,
Floatx,
Floaty,
Floatz,
FloatAngle,
pFile[50],
pLicense,
pName,
pMoney
}
new AllowTele[MAX_PLAYERS]=1,AntiSpam[MAX_PLAYERS]=0,Car[500],CtrArray[MAX_PLAYERS],Amount,Interior,Tele,Type,logged[MAX_PLAYERS],Model,Total,User[MAX_PLAYERS][pInfo],Float,Float:y,Float:z,Float:Angle,Text:welcomeT ext,
CarDB[15] ="DB/Cars.ini",
/*WeaponDB[20] ="DB/Weapons.ini",*/
PickupDB[20] ="DB/Pickups.ini",
Cars[15] ="Load/Cars.ini",
Pickups[30] ="Load/Pickups.ini",
CP[30] ="Load/Checkpoints.ini";
new name[MAX_PLAYER_NAME],String[256];


new Text:SPEEDOS[MAX_PLAYERS],Pickup[200];

thats were its all set
Reply
#9

This is where you create it, but where do you set a value to it?
Reply
#10

Quote:

dini_Create (User[playerid][pFile]);
dini_IntSet (User[playerid][pFile], "HPassword", udb_hash(inputtext[0]));
dini_Set (User[playerid][pFile], "Password", inputtext[0]);
dini_IntSet (User[playerid][pFile], "Interior",0);
dini_IntSet (User[playerid][pFile], "AdminLevel",0);
dini_IntSet (User[playerid][pFile], "Score", 0);
dini_IntSet (User[playerid][pFile], "License", 0);
dini_IntSet (User[playerid][pFile], "Money", 10000);
User[playerid][pAdminLevel] = dini_Int(User[playerid][pFile], "AdminLevel");
User[playerid][px] = dini_Float(User[playerid][pFile], "z");
User[playerid][py] = dini_Float(User[playerid][pFile], "y");
User[playerid][pz] = dini_Float(User[playerid][pFile], "z");
User[playerid][pLicense] = dini_Int(User[playerid][pFile], "License");
User[playerid][pScore] = dini_Int(User[playerid][pFile], "Score");
User[playerid][pMoney] = dini_Int(User[playerid][pFile], "Money");

thats were there set, they are all set when u register
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)