PDA

View Full Version : Name Detection


AceFlyer
19/01/2012, 03:14 AM
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,PlayerName,sizeof(PlayerNam e));
new str[128];
new Vehicle = GetPlayerVehicleID(playerid);
format(str,sizeof(str),"/vehicles/%d",Vehicle);
new ow[MAX_PLAYER_NAME];
format(ow,sizeof(ow),"%s",dini_Get(str,"ownername"));
if(fexist(str)&&strcmp(PlayerName,ow,true))
{
SendClientMessage(playerid,COLOR_WHITE,"You have entered your vehicle");

}
else
{
SendClientMessage(playerid,COLOR_WHITE,"this is not your vehicle");
}


The Problem with that code which is placed under OnPlayerStateChange is that when i enter an owned vehicle it says that i am not in my vehicle while the file says that i am the owner anyone have an idea why?

SuperViper
19/01/2012, 03:32 AM
strcmp(PlayerName,ow,true)

should be

strcmp(PlayerName,ow,true) == 0

AceFlyer
19/01/2012, 04:47 AM
strcmp(PlayerName,ow,true)

should be

strcmp(PlayerName,ow,true) == 0
Still doesnt work :/

T0pAz
19/01/2012, 05:58 AM
Try this. Should work.


new PlayerName[MAX_PLAYER_NAME]; GetPlayerName(playerid,PlayerName,sizeof(PlayerNam e));
new str[128];
new Vehicle = GetPlayerVehicleID(playerid);
format(str, sizeof(str), "/vehicles/%d", Vehicle);
new ow[MAX_PLAYER_NAME];
format(ow, sizeof(ow), "%s", dini_Get(str,"ownername"));
if( (fexist(str)) && (!strcmp(PlayerName,ow,true)))
SendClientMessage(playerid,COLOR_WHITE,"You have entered your vehicle");
else
SendClientMessage(playerid,COLOR_WHITE,"this is not your vehicle");


If not, there is a INI parsing problem I guess.

AceFlyer
19/01/2012, 05:58 AM
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2034.148193,1343.952148,10.820303 Vehicleid:/vehicles/0.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2051.901123,1344.666137,10.671875 Vehicleid:/vehicles/1.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2048.914550,1350.430053,10.671875 Vehicleid:/vehicles/2.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2044.704956,1357.495605,10.671875 Vehicleid:/vehicles/3.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2045.627441,1366.661132,10.671875 Vehicleid:/vehicles/4.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2048.676269,1360.939941,10.671875 Vehicleid:/vehicles/5.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2051.948486,1358.080444,10.671875 Vehicleid:/vehicles/6.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2072.729003,1720.177001,10.671875 Vehicleid:/vehicles/7.ini
[11:21:35] All owned vehicles loaded
[11:21:35] vehicle Loaded, Owner:Ace_Flyer Location 2066.222412,1718.324829,10.671875 Vehicleid:/vehicles/8.ini
[11:21:35] All owned vehicles loaded
[11:21:35] reading vehicle from file /vehicles/0.ini For vehicleid 0
[11:21:35] File Read Owner of Vehicleid 0 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/1.ini For vehicleid 1
[11:21:35] File Read Owner of Vehicleid 1 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/2.ini For vehicleid 2
[11:21:35] File Read Owner of Vehicleid 2 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/3.ini For vehicleid 3
[11:21:35] File Read Owner of Vehicleid 3 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/4.ini For vehicleid 4
[11:21:35] File Read Owner of Vehicleid 4 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/5.ini For vehicleid 5
[11:21:35] File Read Owner of Vehicleid 5 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/6.ini For vehicleid 6
[11:21:35] File Read Owner of Vehicleid 6 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/7.ini For vehicleid 7
[11:21:35] File Read Owner of Vehicleid 7 is now set as Ace_Flyer
[11:21:35] reading vehicle from file /vehicles/8.ini For vehicleid 8
[11:21:35] File Read Owner of Vehicleid 8 is now set as Ace_Flyer


well i tried printing the data on the console to see if it actually reads data and that was a success.
let me try that