check player name is vehicle owner name
#1

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid))
	{
                print("working");
		if(GetPlayerVehicleID(playerid) == dini_Int(File, "CarID"))
		{
                        print("Working2");
			new pln[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pln, sizeof(pln));
			if(strcmp(pln,dini_Get(File, "Owner"),false))// == 0)
			{
				return 1;
			}
			else
			{
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid, RED, "This isn't ur vehicle!");
			}
		}
	}
	return 1;
}
It doesn't work? Where's the problem?

Edit: in the console i see the first working message ( print("working"); )
Reply
#2

BUMP
Reply
#3

pawn Код:
if(GetPlayerVehicleID(playerid) == dini_Int(File, "CarID"))
where you opened file ?!
Reply
#4

hm... How to do it? Can u tell me?
Reply
#5

i didn't use dini at all !
but when you use dini_Int(File, "CarID") , this mean you have opened a file wich called "File" and get an integer from "CarID" value !
if you don't open a file, so you can't get integers and strings and...

if you pay attention:
pawn Код:
print("working");
if(GetPlayerVehicleID(playerid) == dini_Int(File, "CarID"))
{
  print("Working2"); // <---------------
  .............
you can't see "Working2" in consol.
so in this line:
pawn Код:
if(GetPlayerVehicleID(playerid) == dini_Int(File, "CarID"))
you have problem.
and your problem is that you didn't open any file to get information from it
i suggest you use MySQL or Y_ini
MYSQL is very good
Y_INI is better than Dini !
Good luck
Reply
#6

@M4D: dini automatically opens, reads/writes and closes the file at each function. (That's why dini is considered slow).
Reply
#7

for register and login system i use Y-INI, but in this FS i use dini cuz it's more easily. But i stuck here and i don't know what to do, so i write here for little help.
Reply
#8

@Schneider: So..Where we have to define which file we need to open ?
i told i didn't work with dini at all and i don't know how it works
i guess it works same as y ini and you have to open and,,,,
and help dan40o you know dini
Reply
#9

You should at least check if the if statment is true, you could do it like that
pawn Код:
// instead of print("working");
new
    vid = GetPlayerVehicleID(playerid),
    did = dini_Int(File, "CarID")
;
printf("if(%d == %d) %s", vid, did, ((vid == did) ? ("True") : ("False")));
Reply
#10

(1025) : error 001: expected token: "-string end-", but found "-identifier-"

printf("if(%d == %d) %s", vid, did, ((vid == did) ? "True" : "False"));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)