new Lent[MAX_PLAYERS];
new Lent[MAX_PLAYERS][128]; // This initializes a multi-dimensional array with one cell of 500 length and a second cell with 128 length.
if(strcmp(Lent[playerid],"Torran0",true) == 0) // Use strcmp to compare strings
{
// The string stored in the playerid's cell in the Lent array is "Torran0"
}
You want to make a multi-dimensional array and do some string comparison? Well here's a simple example.
pawn Код:
pawn Код:
|
GetPlayerName(playerid,Lent[playerid],sizeof(Lent[playerid]));
format(Lent, Lent[targetid], "Torran0");
Like this then?
[pawn]format(Lent, Lent[targetid], "Torran0");/pawn] |
format(Lent[playerid],sizeof(Lent[playerid]),"Torran0");
C:\Freeroam\Server\filterscripts\cars.pwn(103) : error 001: expected token: "]", but found "-identifier-" C:\Freeroam\Server\filterscripts\cars.pwn(103) : warning 215: expression has no effect C:\Freeroam\Server\filterscripts\cars.pwn(103) : error 001: expected token: ";", but found "]" C:\Freeroam\Server\filterscripts\cars.pwn(103) : error 029: invalid expression, assumed zero C:\Freeroam\Server\filterscripts\cars.pwn(103) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors.
else if(strcmp(Lent[playerid], "Torran0", true) == 0)
RemovePlayerFromVehicle(playerid);
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == Torran[0])
{
if(strcmp(GetName(playerid), "JoeTorran", true) == 0 || strcmp(Lent[playerid], "Torran0", true) == 0)
{
print(" ");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
else if(vehicleid == Torran[1])
{
if(strcmp(GetName(playerid), "JoeTorran", true) == 0 || strcmp(Lent[playerid], "Torran1", true) == 0)
{
print(" ");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
else if(vehicleid == Tik[0])
{
if(strcmp(GetName(playerid), "Tik", true) == 0 || strcmp(Lent[playerid], "Tik0", true) == 0)
{
print(" ");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
else if(vehicleid == Tik[1])
{
if(strcmp(GetName(playerid), "Tik", true) == 0 || strcmp(Lent[playerid], "Tik1", true) == 0)
{
print(" ");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
else if(vehicleid == Tik[2])
{
if(strcmp(GetName(playerid), "Tik", true) == 0 || strcmp(Lent[playerid], "Tik2", true) == 0)
{
print(" ");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
}
return 1;
}
OK, I'm just going to stop you there. I don't know why the code isn't working, but it's not important - you can't restrict access to vehicles based purely on name. SA:MP has no global name registration, so anyone can join your server with any name, including "Torran", or any of the other specified names. To do this you need a full user system with password protected accounts - there are plenty of those available in the release sections, get one of those, integrate it, then come back to this issue.
|
format(Lent, Lent[playerid], "Torran0");