pawn Код:
new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];
new string[300];
new stringtwo[1000];
new WeaponName[47][32];
new Float:temppos[8][4];
new bool:AviableWeapons[47] = {
true,//0
true,//1
true,//2
true,//3
true,//4
true,//5
true,//6
true,//7
true,//8
true,//9
true,//10
true,//11
true,//12
true,//13
true,//14
true,//15
true,//16
false,//17
false,//18
false,//19
false,//20
false,//21
false,//22
true,//23
true,//24
true,//25
false,//26
false,//27
false,//28
true,//29
true,//30
true,//31
false,//32
true,//33
true,//34
false,//35
false,//36
false,//37
false,//38
true,//39
false,//40
false,//41
false,//42
false,//43
false,//44
false,//45
false //46
};
new CountText[9][5] ={
"~r~1",
"~y~2",
"~g~3",
"~w~4",
"~w~5",
"~w~6",
"~w~-",
"~w~-",
"~w~-"
};
enum Dueli
{
dStarted,
dMapID,
dWeapons[2],
dHosterID,
dJoinerID,
dInvitedID,
bool:dArmour
}
new Duel[MAX_DUELS][Dueli];
enum DuelMapsi
{
dmName[MAX_PLAYER_NAME],
Float:mPos1[4],
Float:mPos2[4],
mInterior
}
[COLOR="Red"]new DuelMaps[8][DuelMapsi] = { //i know this
{"YellowBell", {1405.6573,2782.3801,10.8203,86.4400}, {1119.3622,2787.4194,10.8203,283.1986}}, //YellowBell
{"Blueberry Acres", {-99.5206,-62.2486,3.1172,341.2285}, {-53.0461,72.4819,3.1172,159.7951}},
{"MAF1A Box", {1417.363647,-17.101730,1000.926696}, {1363.297485,-4.580797,1000.921875},1},
{"Roof", {2465.0,2360.0,71.0, 90.0}, {2465.0,2390.0,71.0, 270.0}},
{"Whetstone Beach", {-2664.6118,-2332.4331,3.0000, 180.0}, {-2664.6118,-2383.4331,3.0000}},
{"Hampton Barns", {752.338073,248.825393,27.092527}, {764.974914,377.301727,23.206260,180.0}},
{"Blueberry", {211.9796,-174.8186,1.5781,88.0241}, {80.9424,-178.5773,1.5681,267.8557}},
{"SF Airport", {-1309.0671,-193.6552,14.1484,316.0927}, {-1251.0068,-135.5645,14.1484,131.9633}}
}; //i know this
[/COLOR]
enum Playeri
{
pDuelCount,
Float:pHP
}
new Player[MAX_PLAYERS][Playeri];
public OnFilterScriptInit() //DONT CHANGE THIS!!!!!!!!!!!1
{
for(new i=0; i<20; i++) ResetDuelVariables(i);
for(new i; i<47; i++)
{
if(i == 0) WeaponName[i] = "Fists/Legs";
else if(i == 1) WeaponName[i] = "BrassKnu";
else if(i == 0) WeaponName[i] = "Fists/Legs";
else if(i == 4) WeaponName[i] = "Knifecur";
else if(i == 18) WeaponName[i] = "Molotov";
else if(i == 23) WeaponName[i] = "Silenced";
else if(i == 24) WeaponName[i] = "Deagle";
else if(i == 26) WeaponName[i] = "Sawn";
else if(i == 27) WeaponName[i] = "SPAZ 12";
else if(i == 28) WeaponName[i] = "Ingramm";
else if(i == 29) WeaponName[i] = "MP5lng";
else if(i == 30) WeaponName[i] = "Kalash";
else if(i == 31) WeaponName[i] = "M4A1";
else if(i == 32) WeaponName[i] = "Tec9";
else if(i == 35) WeaponName[i] = "Launcher";
else if(i == 36) WeaponName[i] = "HeatSeek";
else if(i == 37) WeaponName[i] = "Flameth";
else if(i == 18) WeaponName[i] = "Molotov";
else if(i == 39) WeaponName[i] = "Satchel";
else if(i == 42) WeaponName[i] = "Fire ex";
else if(i == 45) WeaponName[i] = "Heat Seek Vision";
else GetWeaponName(i, WeaponName[i], 32);
}
for(new i; i<GetMaxPlayers(); i++)
{
GetPlayerName(i, PlayerName[i], MAX_PLAYER_NAME);
}
print("\n\n\nFilterscript "#NAME" started succesful.\nVersion"#VERSION" from "#DATE"\nby S2D.Alone_ [sentence2death.ru]\n\n");
return 1;
}
public OnPlayerConnect(playerid) //DONT CHANGE THIS!!!!!!!!!!!
{
GetPlayerName(playerid, PlayerName[playerid], MAX_PLAYER_NAME);
SendClientMessage(playerid, COLOR_INFO, ""#INFO" This server using FS "#NAME" version "#VERSION" from "#DATE" (/duel)");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new duelid = GetPlayerDuelID(playerid);
if(duelid != 0)
{
if(Duel[duelid][dHosterID] == playerid) EndDuel(Duel[duelid][dJoinerID], duelid);
else if(Duel[duelid][dJoinerID] == playerid) EndDuel(Duel[duelid][dHosterID], duelid);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new duelid = GetPlayerDuelID(playerid);
if(duelid != 0)
{
if(Duel[duelid][dHosterID] == playerid) EndDuel(Duel[duelid][dJoinerID], duelid);
else if(Duel[duelid][dJoinerID] == playerid) EndDuel(Duel[duelid][dHosterID], duelid);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerColor(playerid, COLOR_DUEL); //i know this
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx; // idk this
cmd = strtok(cmdtext, idx); //idk this
if(strcmp(cmd, "/duel", true) == 0) //idk 0
{
SendClientMessage(playerid, COLOR_LIST_HEADER, ""#HEADER" Help for Advance Duel System:");
SendClientMessage(playerid, COLOR_LIST_ITEM, ""#ITEM" "#USAGE_DUEL" - create duel");
SendClientMessage(playerid, COLOR_LIST_ITEM, ""#ITEM" /duelj [duel ID] - join to duel");
SendClientMessage(playerid, COLOR_LIST_ITEM, ""#ITEM" /dueldec - decline duel invite");
SendClientMessage(playerid, COLOR_LIST_ITEM, ""#ITEM" /dueldel - delete duel");
SendClientMessage(playerid, COLOR_LIST_ITEM, ""#ITEM" /duelloc - list of locations");
SendClientMessage(playerid, COLOR_LIST_ITEM, ""#ITEM" /duelwep - list of aviable weapons");
return 1;
} // i know this
else if(strcmp(cmd, "/duel", true) == 0)
{
new duelid = GetPlayerDuelID(playerid);
if(duelid == 0)
{
new tmp1[TMP_SIZE];
new tmp2[TMP_SIZE];
new tmp3[TMP_SIZE];
new tmp4[TMP_SIZE];
new tmp5[TMP_SIZE];
new inv = INVALID_PLAYER_ID;
tmp1 = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);
tmp3 = strtok(cmdtext, idx);
tmp4 = strtok(cmdtext, idx);
tmp5 = strtok(cmdtext, idx);
if(strlen(tmp5) == 0) inv = INVALID_PLAYER_ID;
else inv = strval(tmp5);
new errorid = CreateDuel(playerid,strval(tmp1),strval(tmp2),strval(tmp3),strval(tmp4),inv);
switch(errorid)
{
case -8: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" All duels ("#MAX_DUELS") already created. Wait please"),SendClientMessage(playerid, COLOR_USAGE,""#USAGE" "#USAGE_DUEL"");
case -2: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Wrong location ID"),SendClientMessage(playerid, COLOR_USAGE,""#USAGE" "#USAGE_DUEL"");
case -3: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Wrong primary weapon ID"),SendClientMessage(playerid, COLOR_USAGE,""#USAGE" "#USAGE_DUEL"");
case -4: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Wrong primary weapon ID"),SendClientMessage(playerid, COLOR_USAGE,""#USAGE" "#USAGE_DUEL"");
case -5: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Player is disconnected"),SendClientMessage(playerid, COLOR_USAGE,""#USAGE" "#USAGE_DUEL"");
case -6: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Player already on duel"),SendClientMessage(playerid, COLOR_USAGE,""#USAGE" "#USAGE_DUEL"");
case -7: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Impossible invite youself"),SendClientMessage(playerid, COLOR_USAGE,""#USAGE" "#USAGE_DUEL"");
}
}
else SendClientMessage(playerid, COLOR_ERROR,""#ERROR" You already created duel");
return 1;
}
else if(strcmp(cmd, "/duelj", true) == 0)
{
new duelid = GetPlayerDuelID(playerid);
if(duelid == 0 || (duelid != 0 && Duel[duelid][dStarted] != 1))
{
new tmp1[TMP_SIZE];
tmp1 = strtok(cmdtext, idx);
if(strval(tmp1) <= 0)
{
SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Wrong duel ID");
}
else
{
if(duelid != 0 && Duel[duelid][dInvitedID] != playerid && Duel[duelid][dStarted] != 1) ResetDuelVariables(duelid);
new errorid = StartDuel(playerid,strval(tmp1));
switch(errorid)
{
case -2: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" This duel ID hasn't been created. Create your duel by /duel");
case -3: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" On this duel ID already playing. Create your duel by /duel");
case -4: SendClientMessage(playerid, COLOR_ERROR,""#ERROR" This is private duel ID. Create different duel by /duel");
}
}
}
else SendClientMessage(playerid, COLOR_ERROR,""#ERROR" You already on duel");
return 1;
}
else if(strcmp(cmd, "/dueldec", true) == 0)
{
new duelid = GetPlayerDuelID(playerid);
if(duelid == 0)
{
SendClientMessage(playerid, COLOR_ERROR,""#ERROR" You uninvited. Create your duel by /duel");
}
else
{
if(Duel[duelid][dStarted] == 1)
{
SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Impossible decline duel, when she has been started");
}
else
{
format(string, sizeof(string), "%s decline invite to duel. Duel was deleted", PlayerName[playerid]);
SendClientMessage(Duel[duelid][dHosterID], COLOR_DUEL, string);
ResetDuelVariables(duelid);
SendClientMessage(playerid, COLOR_DUEL, "You decline invite to duel");
}
}
return 1;
}
else if(strcmp(cmd, "/dueldel", true) == 0)
{
new duelid = GetPlayerDuelID(playerid);
if(duelid == 0)
{
SendClientMessage(playerid, COLOR_ERROR,""#ERROR" You haven't duel. Create your duel by /duel");
}
else
{
if(Duel[duelid][dStarted] == 1)
{
SendClientMessage(playerid, COLOR_ERROR,""#ERROR" Impossible delete duel, when she has been started");
}
else
{
ResetDuelVariables(duelid);
format(string, sizeof(string), "%s delete duel (ID: %d)", PlayerName[playerid], duelid);
SendClientMessageToAll(COLOR_DUEL, string);
}
}
return 1;
}
else if(strcmp(cmd, "/duelloc", true) == 0)
{
strdel(stringtwo, 0, strlen(stringtwo));
for(new i; i<sizeof(DuelMaps); i++)
{
format(string, sizeof(string), "\t%d-%s\n", i, DuelMaps[i][dmName]);
strcat(stringtwo, string);
}
ShowPlayerDialog(playerid, 9900, 0, "Locations list of Duel System", stringtwo, "OK", "Exit");
return 1;
}
else if(strcmp(cmd, "/duelwep", true) == 0)
{
strdel(stringtwo, 0, strlen(stringtwo));
new stolbeg = 0;
for(new i=0; i<47; i++)
{
if(AviableWeapons[i] == true)
{
format(string, sizeof(string), "%d-%s", i, WeaponName[i]);
strcat(stringtwo, string);
if(stolbeg == 0) strcat(stringtwo, "\t");
else strcat(stringtwo, "\n");
stolbeg++;
if(stolbeg > 1) stolbeg = 0;
}
}
ShowPlayerDialog(playerid, 9900, 0, "Aviable weapons of Duel System", stringtwo, "OK", "Exit");
return 1;
}
}
ResetDuelVariables(duelid)
{
Duel[duelid][dStarted] = -1;
Duel[duelid][dArmour] = false;
Duel[duelid][dMapID] = -1;
Duel[duelid][dWeapons][0] = 0;
Duel[duelid][dWeapons][1] = 0;
Duel[duelid][dHosterID] = INVALID_PLAYER_ID;
Duel[duelid][dJoinerID] = INVALID_PLAYER_ID;
Duel[duelid][dInvitedID] = INVALID_PLAYER_ID;
Duel[duelid][dArmour] = false;
}
GetFirstDuelID()//DONT CHANGE THIS!!!!!!!!!!!!
{
for(new i=1; i<MAX_DUELS; i++) if(Duel[i][dStarted] == -1) return i;
return 0;
}
GetPlayerDuelID(playerid)//DONT CHANGE THIS!!!!!!!!!!!!
{
for(new i=1; i<MAX_DUELS; i++) if(Duel[i][dHosterID] == playerid || Duel[i][dJoinerID] == playerid || Duel[i][dInvitedID] == playerid) return i;
return 0;
}
CreateDuel(playerid, mapid, weaponid1, weaponid2, armour, inviteid = INVALID_PLAYER_ID)
{
if(IsPlayerConnected(playerid) == 0) return -1;
if(mapid >= sizeof(DuelMaps) || mapid <= -1) return -2;
if(AviableWeapons[weaponid1] == false) return -3;
if(AviableWeapons[weaponid1] == false) return -4;
if(playerid == inviteid && inviteid != INVALID_PLAYER_ID) return -7;
if(IsPlayerConnected(inviteid) == 0 && inviteid != INVALID_PLAYER_ID) return -5;
if(GetPlayerDuelID(inviteid) != 0 && inviteid != INVALID_PLAYER_ID) return -6;
new duelid = GetFirstDuelID();
if(duelid == 0) return -8;
Duel[duelid][dStarted] = 0;
Duel[duelid][dMapID] = mapid;
Duel[duelid][dWeapons][0] = weaponid1;
Duel[duelid][dWeapons][1] = weaponid2;
Duel[duelid][dHosterID] = playerid;
Duel[duelid][dJoinerID] = INVALID_PLAYER_ID;
if(armour) Duel[duelid][dArmour] = true;
else Duel[duelid][dArmour] = false;
//0xffd400ff
if(weaponid1 == weaponid2) format(string, sizeof(string), "%s", WeaponName[weaponid1]);
else format(string, sizeof(string), "%s + %s",WeaponName[weaponid1],WeaponName[weaponid2]);
if(inviteid == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "%s has created duel (ID: %d) on location %s(%d) (Armour: %d). Weapon %s",
PlayerName[playerid], duelid, DuelMaps[mapid][dmName],mapid, armour, string, duelid);
SendClientMessageToAll(COLOR_DUEL, string);
format(string, sizeof(string), "HINT: Write \"/duelj %d\" for join to duel", duelid);
SendClientMessageToAll(COLOR_HINT, string);
}
else
{
Duel[duelid][dInvitedID] = inviteid;
format(string, sizeof(string), "You invited %s on duel (ID: %d) on location %s(%d) (Armour: %d). Weapon %s",
PlayerName[inviteid], duelid, DuelMaps[mapid][dmName],mapid, armour, string);
SendClientMessage(playerid, COLOR_DUEL, string);
if(weaponid1 == weaponid2) format(string, sizeof(string), "%s", WeaponName[weaponid1]);
else format(string, sizeof(string), "%s + %s",WeaponName[weaponid1],WeaponName[weaponid2]);
format(string, sizeof(string), "%s invited you to duel (ID: %d) on location %s(%d) (Armour: %d). Weapon %s",
PlayerName[playerid], duelid, DuelMaps[mapid][dmName],mapid, armour, string);
SendClientMessage(inviteid, COLOR_DUEL, string);
format(string, sizeof(string), "HINT: Write \"/duelj %d\" for join or \"/dueldec\" for decline", duelid);
SendClientMessage(inviteid, COLOR_HINT, string);
GameTextForPlayer(inviteid, "Look at the chat~n~the chat is amazing!", 5000, 3);
}
format(string, sizeof(string), "HINT: For delete duel write /dueld");
SendClientMessage(playerid, COLOR_HINT, string);
return 0;
}
StartDuel(joinid, duelid)
{
if(IsPlayerConnected(joinid) == 0) return -1; //не подключён
if(Duel[duelid][dStarted] == -1) return -2;
if(Duel[duelid][dStarted] == 1) return -3;
if(Duel[duelid][dInvitedID] != INVALID_PLAYER_ID && Duel[duelid][dInvitedID] != joinid) return -4;
Duel[duelid][dStarted] = 1;
Duel[duelid][dJoinerID] = joinid;
spawnPlayerEx(Duel[duelid][dHosterID]);
spawnPlayerEx(Duel[duelid][dJoinerID]);
format(string, sizeof(string), "Duel (ID: %d) %s vs %s has been started",
duelid, PlayerName[Duel[duelid][dHosterID]], PlayerName[Duel[duelid][dJoinerID]]);
SendClientMessageToAll(COLOR_DUEL, string);
Player[Duel[duelid][dHosterID]][pDuelCount] = 6;
Player[Duel[duelid][dJoinerID]][pDuelCount] = 6;
SetTimerEx("PlayerCount", 1000, 0, "d", Duel[duelid][dHosterID]);
SetTimerEx("PlayerCount", 1000, 0, "d", Duel[duelid][dJoinerID]);
return 0;
}
spawnPlayerEx(i)
{
if(GetPlayerState(i) == 9) {return TogglePlayerSpectating(i, false);}
if(GetPlayerState(i) == PLAYER_STATE_WASTED || GetPlayerState(i) == PLAYER_STATE_NONE ) return 1;
if(IsPlayerInAnyVehicle(i))
{
SetPlayerPos(i, 0.0, 0.0, 9900.0);
}
SpawnPlayer(i);
return 1;
}
forward PlayerCount(playerid);
public PlayerCount(playerid)
{
if(Player[playerid][pDuelCount] > 0)
{
if(Player[playerid][pDuelCount] == 6)
{
new duelid = GetPlayerDuelID(playerid);
if(duelid != 0 && Duel[duelid][dStarted] == 1)
{
if(Duel[duelid][dHosterID] == playerid) SetPlayerColor(playerid,0x00FFFF00);
else if(Duel[duelid][dJoinerID] == playerid) SetPlayerColor(playerid,0x00FF0000);
SetPlayerVirtualWorld(playerid, Duel[duelid][dHosterID]+20);
if(Duel[duelid][dHosterID] == playerid) SetPlayerPos(playerid,
DuelMaps[Duel[duelid][dMapID]][mPos2][0],DuelMaps[Duel[duelid][dMapID]][mPos2][1],
DuelMaps[Duel[duelid][dMapID]][mPos2][2]),SetPlayerFacingAngle(playerid, DuelMaps[Duel[duelid][dMapID]][mPos2][3]);
else if(Duel[duelid][dJoinerID] == playerid) SetPlayerPos(playerid,
DuelMaps[Duel[duelid][dMapID]][mPos1][0],DuelMaps[Duel[duelid][dMapID]][mPos1][1],
DuelMaps[Duel[duelid][dMapID]][mPos1][2]),SetPlayerFacingAngle(playerid, DuelMaps[Duel[duelid][dMapID]][mPos1][3]);
SetPlayerInterior(playerid, DuelMaps[Duel[duelid][dMapID]][mInterior]);
SetPlayerHealth(playerid, 100.0);
if(Duel[duelid][dArmour] == true) SetPlayerArmour(playerid, 100.0);
else SetPlayerArmour(playerid, 0.0);
}
}
TogglePlayerControllable(playerid, false);
Player[playerid][pDuelCount]--;
format(string,256," ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ %s ~n~ %s ~n~ %s ~n~ ",CountText[Player[playerid][pDuelCount]+2],CountText[Player[playerid][pDuelCount]+1],CountText[Player[playerid][pDuelCount]]);
GameTextForPlayer(playerid, string, 1200, 3);
SetTimerEx("PlayerCount", 1000, 0, "d", playerid);
SetCameraBehindPlayer(playerid);
ShowPlayerDialog(playerid, -1, 0, "Оружия Advance Duel System", stringtwo, "OK", "Выход");
}
else
{
new duelid = GetPlayerDuelID(playerid);
TogglePlayerControllable(playerid, true);
ResetPlayerWeapons(playerid);
if(Duel[duelid][dWeapons][0] == Duel[duelid][dWeapons][1]) GivePlayerWeapon(playerid, Duel[duelid][dWeapons][0], 9900);
else GivePlayerWeapon(playerid, Duel[duelid][dWeapons][0], 9900),GivePlayerWeapon(playerid, Duel[duelid][dWeapons][1], 9900);
format(string,256," ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ %s ~n~ %s ~n~ ~w~GO GO GO! ~n~ ",CountText[Player[playerid][pDuelCount]+1],CountText[Player[playerid][pDuelCount]]);
GameTextForPlayer(playerid, string, 1200, 3);
Player[playerid][pDuelCount] = -1;
}
return 1;
}
EndDuel(winnerid, duelid)
{
if(Duel[duelid][dStarted] != 1) return -1;
GetPlayerHealth(winnerid, temppos[0][1]);
GetPlayerArmour(winnerid, temppos[0][2]);
Player[winnerid][pHP] = temppos[0][1] + temppos[0][2];
format(string, sizeof(string), "%s (%.0f HP) has win id duel (ID: %d)", PlayerName[winnerid],Player[winnerid][pHP],duelid);
SendClientMessageToAll(COLOR_DUEL, string);
Duel[duelid][dStarted] = -1;
spawnPlayerEx(Duel[duelid][dHosterID]);
spawnPlayerEx(Duel[duelid][dJoinerID]);
ResetDuelVariables(duelid);
return 0;
}
strtok(const string2[], &index)
{
new length = strlen(string2);
while ((index < length) && (string2[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string2[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string2[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Basically the guy who made the script made an array of AvailableWeapons, so that means you have 47 variables of AvailableWeapons, and for each of them he set them to true (available) and false (not available).
Later on, under the OnFilterScriptInit() called when the filterscript is initialized he sets the name of the weapons by number.
I can't really explain it all, it's really a lot, just tell me at what specific part you want me to explain what he did.
You can't just open a script and expect to learn from that as a whole, you need to start with small things. The wiki doesn't necessarily 'teach' you completely, it's mainly to learn the syntax of functions. However the examples can sometimes be useful as they are simple.
Start with variables, callbacks etc. then move on to arrays and shit. Arrays are not a good starting point.