Am besten ist die variante hier, ist aber nur mit AddStaticVehicle machbar. Das AddPlayerClass kannst du dann entfernen wenn du Join Ped und new Ped im script hasst.
new SelectChar[MAX_PLAYERS];
new SelectCharID[MAX_PLAYERS];
new SelectCharPlace[MAX_PLAYERS];
forward IsASFCopCar(palyerid);
forward IsASFCop(playerid);
forward SetPlayerToTeamColor(playerid);
// Fraktion Skins
new Join Ped[3][1]{
{280},
{281},
{282}
};
// Spieler Skins
new Peds[2][1] = {
{29},
{288}
}
Jetzt erstellen wir die Fraktion SFPolice, das Kommt nach dem Main
public IsASFCop(playerid)
{
if(IsPlayerConnected(playerid))
{
new leader = PlayerInfo[playerid][pLeader];
new member = PlayerInfo[playerid][pMember];
if(member==1)
{
return 1;
}
else if(leader==1)
{
return 1;
}
}
return 0;
}
DIe Zahl 1 bedeutet Welche Fraktion reihe es ist ob 1 oder 30 ist egal. Es muss nachher nur zusammen passen.
Nun kommen wir zu den Fahrzeugen, die werden definiert nur von bestimmten Fraktion benutzt werden können. Welche das denn sind ist dir überlassen.
public IsASFCopCar(carid)
{
if(GetVehicleModel(carid) == 415 || GetVehicleModel(carid) == 427 || GetVehicleModel(carid) == 497 || GetVehicleModel(carid) == 506 || GetVehicleModel(carid) == 528 || GetVehicleModel(carid) == 586 || GetVehicleModel(carid) == 597 || GetVehicleModel(carid) == 599 || GetVehicleModel(carid) == 601)
{
return 1;
}
return 0;
}
Bei public OnPlayerStateChange(playerid, newstate, oldstate) fügst das hier ein,
new string[256];
if(newstate == PLAYER_STATE_DRIVER)
{
if(IsASFCopCar(newcar))
{
if(IsASFCop(playerid)) { }
else { RemovePlayerFromVehicle(playerid); }
}
if(newcar == 1 || newcar == 2 || newcar == 3 || newcar == 4 || newcar == 5 || newcar == 6 || newcar == 7 || newcar == 8 || newcar == 9 || newcar == 10 || newcar == 11 || newcar == 12 || newcar == 13 || newcar == 14 || newcar == 15 || newcar == 16 || newcar == 17 || newcar == 18 || newcar == 19 || newcar == 20 || newcar == 21 || newcar == 22 || newcar == 23 || newcar == 24 || newcar == 25 || newcar == 26)
{
if(!IsASFCop(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Du bist kein SF Polizist!");
RemovePlayerFromVehicle(playerid);
}
else { }
}
}
return 1;
}
unter SetPalyerSpawn kommt das hier
public SetPlayerSpawn(playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pMember] == 1)//Police Spawn
{
SetPlayerToTeamColor(playerid);
GivePlayerWeapon(playerid, 29, 300); //MP%
GivePlayerWeapon(playerid, 24, 300); //Pistole
SetPlayerInterior(playerid, 5); // darauf achten, wenn du in ein innenraum Spawns immer die richtige Inetrior Nummer setzen
SetPlayerPos(playerid, 1292.4521,-804.6435,1089.9375); // Hier kannst du einen Spawn setzen egal welchen / Police Department
SetPlayerFacingAngle(playerid,266.4193);
return 1;
}
}
return 1;
}
Unter OnPalyerSpawn
SetPlayerToTeamColor(playerid);
Das ist die TeamColor
public SetPlayerToTeamColor(playerid)
{
if(IsPlayerConnected(playerid))
{
else if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
{
SetPlayerColor(playerid,0x0000FF00); // CopfarbeSF
}
else
{
SetPlayerColor(playerid,TEAM_HIT_COLOR); // white
}
}
}
Als nächstes kommt unser OnPlayerText
public OnPlayerText(playerid, text[])
{
new giver[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new tmp[256];
new string[256];
new giveplayerid;
if(SelectChar[playerid] == 255)
{
new idx;
tmp = strtok(text, idx);
if ((strcmp("next", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("next")))
{
switch (SelectCharID[playerid])
{
case 1: //Police Force SF
{
if(SelectCharPlace[playerid] == 1) { SetPlayerSkin(playerid, JoinPed[0][0]); SelectCharPlace[playerid] = 2; ChosenSkin[playerid] = JoinPed[0][0]; }
else if(SelectCharPlace[playerid] == 2) { SetPlayerSkin(playerid, JoinPed[1][0]); SelectCharPlace[playerid] = 3; ChosenSkin[playerid] = JoinPed[1][0]; }
else if(SelectCharPlace[playerid] == 3) { SetPlayerSkin(playerid, JoinPed[2][0]); SelectCharPlace[playerid] = 1; ChosenSkin[playerid] = JoinPed[2][0]; }
}
}
return 0;
}
else if ((strcmp("done", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("done")))
{
if(ChangePos2[playerid][1] == 1)
{
SetPlayerInterior(playerid, ChangePos2[playerid][0]);
SetPlayerPos(playerid, ChangePos[playerid][0],ChangePos[playerid][1],ChangePos[playerid][2]);
ChangePos2[playerid][1] = 0;
return 0;
}
PlayerInfo[playerid][pModel] = ChosenSkin[playerid];
PlayerInfo[playerid][pChar] = ChosenSkin[playerid];
SetSpawnInfo(playerid, PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pModel],0.0,0.0,0.0,0,0,0,0,0,0,0);
gTeam[playerid] = PlayerInfo[playerid][pTeam];
SetPlayerToTeamColor(playerid);
SpawnPlayer(playerid);
SelectCharPlace[playerid] = 0;
SelectCharID[playerid] = 0;
SelectChar[playerid] = 0;
return 0;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Use 'next', or 'done'.");
return 0;
}
}
return 1;
}
Und zu guter letzt das du auch die Frak nutzen kannst den makeleader befehl
if(strcmp(cmd, "/makeleader", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "FEHLER: /makeleader [playerid] [Number(1-2)]");
return 1;
}
new para1;
new level;
para1 = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
level = strval(tmp);
if(level > 2 || level < 0) { SendClientMessage(playerid, COLOR_GREY, " Die Zahl darf nicht unter 1 oder über 2 sein!"); return 1; }
if (PlayerInfo[playerid][pAdmin] >= 1337)
{
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
if(PlayerInfo[para1][pMember] > 0 || PlayerInfo[para1][pFMember] < 255)
{
SendClientMessage(playerid, COLOR_GREY, " Der Spieler ist bereits in einer Fraktion!");
return 1;
}
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[para1][pLeader] = level;
format(string, sizeof(string), " Du wurdest vom Admin %s zum Leader deiner Fraktion gemacht", sendername);
SendClientMessage(para1, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), " Du hast %s zum Leader der %d Fraktion gemacht.", giveplayer,level);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
if(level == 0) { PlayerInfo[para1][pChar] = 0; }
else if(level == 1) { PlayerInfo[para1][pChar] = 280; {PlayerInfo[para1][pTeam] = 2; }} //PoliceSF
gTeam[para1] = 11;
PlayerInfo[para1][pTeam] = 11;
SetPlayerSkin(para1, PlayerInfo[para1][pChar]);
}
}//not connected
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Du bist kein Admin");
}
}
return 1;
}
Das müsste alles gewesen sein. Wenn ich irgendetwas vergessen habe oder mich verschrieben habe sagt es mir bitte, danke. Ich hoffe das ich dir helfen konnte Bad Company.