Egyszeru.
Példascript
#include <a_samp>
#define red 0xFF9900AA
#define yellow 0xFFFF00AA
new MyCar;
new MyCar2;
public OnFilterScriptInit()
{
MyCar = CreateVehicle(123, 4.5, 6.7, 8.9, 1.0, 1, 2, 0);
MyCar2 = CreateVehicle(123, 4.5, 6.7, 8.9, 1.0, 1, 2, 0);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new Vehicle = GetPlayerVehicleID(playerid);
if(strcmp(cmdtext, \"/lock\", true) == 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i = 0; i <MAX_PLAYERS; i++)
{
if (i != playerid)
{
SetVehicleParamsForPlayer(Vehicle, i, 0, 1);
PlayerPlaySound(playerid,1057, 0.0, 0.0, 0.0);
SendClientMessage(playerid, yellow, \"Jármu lezárva!\");
}
}
} else { SendClientMessage(playerid, red, \"Nem ülsz jármuben!\"); }
return 1;
}
if(strcmp(cmdtext, \"/unlock\", true) == 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i = 0; i <MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(Vehicle, i, 0, 0);
PlayerPlaySound(playerid,1057, 0.0, 0.0, 0.0);
SendClientMessage(playerid, yellow, \"Jármu kinyitva!\");
}
} else { SendClientMessage(playerid, red, \"Nem ülsz jármuben!\"); }
return 1;
}
return 0;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(newstate == PLAYER_STATE_DRIVER)
{
new Vehicle = GetPlayerVehicleID(playerid);
if(Vehicle == MyCar || Vehicle == MyCar2)
{
if(strcmp(PlayerName, \"neved\", true))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0x33AA33AA, \"Nem szállhatsz be \'neved\' autójába!\");
}
}
}
return 1;
}
Le is zárja az autót, és csak egy bizonyos névvel lehet beleülni.
Egyszeru.
Példascript
#include <a_samp>
#define red 0xFF9900AA
#define yellow 0xFFFF00AA
new MyCar;
new MyCar2;
public OnFilterScriptInit()
{
MyCar = CreateVehicle(123, 4.5, 6.7, 8.9, 1.0, 1, 2, 0);
MyCar2 = CreateVehicle(123, 4.5, 6.7, 8.9, 1.0, 1, 2, 0);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new Vehicle = GetPlayerVehicleID(playerid);
if(strcmp(cmdtext, \"/lock\", true) == 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i = 0; i <MAX_PLAYERS; i++)
{
if (i != playerid)
{
SetVehicleParamsForPlayer(Vehicle, i, 0, 1);
PlayerPlaySound(playerid,1057, 0.0, 0.0, 0.0);
SendClientMessage(playerid, yellow, \"Jármu lezárva!\");
}
}
} else { SendClientMessage(playerid, red, \"Nem ülsz jármuben!\"); }
return 1;
}
if(strcmp(cmdtext, \"/unlock\", true) == 0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i = 0; i <MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(Vehicle, i, 0, 0);
PlayerPlaySound(playerid,1057, 0.0, 0.0, 0.0);
SendClientMessage(playerid, yellow, \"Jármu kinyitva!\");
}
} else { SendClientMessage(playerid, red, \"Nem ülsz jármuben!\"); }
return 1;
}
return 0;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(newstate == PLAYER_STATE_DRIVER)
{
new Vehicle = GetPlayerVehicleID(playerid);
if(Vehicle == MyCar || Vehicle == MyCar2)
{
if(strcmp(PlayerName, \"neved\", true))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0x33AA33AA, \"Nem szállhatsz be \'neved\' autójába!\");
}
}
}
return 1;
}
Le is zárja az autót, és csak egy bizonyos névvel lehet beleülni.
if(strcmp(PlayerName, \"neved\", true))
Ez helyett sztem.:
if(strcmp(PlayerName, \"neved\"))
Nállam így muködött :) A true-s verziónál errorozott...
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
if(!strcmp(name, \"neved\", false))
Ezzel tökéletes. igazzal [true] nekem is rossz volt.
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
if(!strcmp(name, \"neved\", false))
Ezzel tökéletes. igazzal [true] nekem is rossz volt.
én elhanyagoltam egyszeruen a true/false-t se error se warning de még tesztelve nem volt :/