19.08.2012, 22:21
pawn Код:
if(strcmp(cmd, "/trunk", true) == 0) // By LordMan
{
if(IsPlayerConnected(playerid))
{
new x_nr[24];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: /trunk [name]");
SendClientMessage(playerid, COLOR_WHITE, "Available names: info, putgun, takegun, putarmour, takearmour");
if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 2)
{
SendClientMessage(playerid, COLOR_WHITE, "You can /trunk frisk as a cop");
}
return 1;
}
if(strcmp(x_nr,"info",true) == 0)
{
new counter = 0;
new result;
new plyName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
for(new i; i != MAX_VEHICLES; i++)
{
new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, COLOR_GREY, " No cars with trunk near you");
}
case 1:
{
if(IsAnOwnableCar(result))
{
if(PlayerInfo[playerid][pPcarkey] == result) { }
else if(PlayerInfo[playerid][pPcarkey2] == result) { }
else
{
SendClientMessage(playerid, COLOR_GREY, " Trunk is locked !");
return 1;
}
}
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You can't open the trunk while you're in the car");
return 1;
}
if(IsAPlane(result) || IsABike(result) || IsAOBike(result) || IsABoat(result) || IsAPizzabike(result) || IsABus(result) || IsATowcar(result) || IsAHarvest(result) || IsADrugHarvest(result) || IsASweeper(result) || result >=78 && result <= 83 || GetVehicleModel(GetPlayerVehicleID(result)) == 523)
{
SendClientMessage(playerid, COLOR_GREY, " This vehicle doesn't have the trunk !");
return 1;
}
SendClientMessage(playerid, COLOR_LIGHT_BLUE, "|_______ Vehicle Trunk _______|");
for(new slot = 1; slot != MAX_TRUNK_SLOTS; slot++)
{
new gunname[24];
if(vehTrunk[result][slot] != 0)
{
GetWeaponName(vehTrunk[result][slot], gunname, sizeof(gunname));
format(string, sizeof(string), "| Slot %i: %s (Ammo: %i)", slot, gunname, vehTrunkAmmo[result][slot]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else
{
format(string, sizeof(string), "| Slot %i: Empty (Ammo: N/A)", slot);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
format(string, sizeof(string), "| Body armour: %f%", vehTrunkArmour[result]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s opens the trunk and checks what is inside.", sendername);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
return 1;
}
default:
{
SendClientMessage(playerid, COLOR_GREY, " Found more then one car in range");
return 1;
}
}
return 1;
}
else if(strcmp(x_nr,"putgun",true) == 0)
{
new counter = 0;
new result;
new plyName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
for(new i; i != MAX_VEHICLES; i++)
{
new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, COLOR_GREY, " No cars with trunk near you");
}
case 1:
{
if(vehTrunkCounter[result] != (MAX_TRUNK_SLOTS-1))
{
if(IsAnOwnableCar(result))
{
if(PlayerInfo[playerid][pPcarkey] == result) { }
else if(PlayerInfo[playerid][pPcarkey2] == result) { }
else
{
SendClientMessage(playerid, COLOR_GREY, " Trunk is locked !");
return 1;
}
}
if(ReduceTime[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, " You need to wait 3 seconds before using this command !");
return 1;
}
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You can't open the trunk while you're in the car");
return 1;
}
if(IsAPlane(result) || IsABike(result) || IsAOBike(result) || IsABoat(result) || IsAPizzabike(result) || IsABus(result) || IsATowcar(result) || IsAHarvest(result) || IsADrugHarvest(result) || IsASweeper(result) || result >=78 && result <= 83|| GetVehicleModel(GetPlayerVehicleID(result)) == 523)
{
SendClientMessage(playerid, COLOR_GREY, " This vehicle doesn't have the trunk !");
return 1;
}
new buffer[128];
new gunname[24];
new gunID = GetPlayerWeapon(playerid);
new gunAmmo = GetPlayerAmmo(playerid);
if(gunID != 0 && gunAmmo != 0)
{
ReduceTime[playerid] = 1;
SetTimerEx("ReduceTimer", 3000, false, "i", playerid);
GetWeaponName(gunID, gunname, sizeof(gunname));
vehTrunkCounter[result]++;
vehTrunk[result][vehTrunkCounter[result]] = gunID;
vehTrunkAmmo[result][vehTrunkCounter[result]] = gunAmmo;
format(buffer, sizeof(buffer), "You have put your %s (Ammo: %i) in the car's trunk.", gunname, gunAmmo);
SendClientMessage(playerid, COLOR_WHITE, buffer);
RemovePlayerWeapon(playerid, gunID);
format(string, sizeof(string), "* %s opens car's trunk and puts a weapon there.", sendername);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
SaveTrunk();
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Car's trunk is full");
return 1;
}
}
default:
{
SendClientMessage(playerid, COLOR_GREY, " Found more then one car in range");
return 1;
}
}
return 1;
}
else if(strcmp(x_nr,"takegun",true) == 0)
{
new counter = 0;
new result;
new plyName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
for(new i; i != MAX_VEHICLES; i++)
{
new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, COLOR_GREY, " No cars with trunk near you");
return 1;
}
case 1:
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You can't open the trunk while you're in the car");
return 1;
}
if(ReduceTime[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, " You need to wait 3 seconds before using this command !");
return 1;
}
if(IsAnOwnableCar(result))
{
if(PlayerInfo[playerid][pPcarkey] == result) { }
else if(PlayerInfo[playerid][pPcarkey2] == result) { }
else
{
SendClientMessage(playerid, COLOR_GREY, " Trunk is locked !");
return 1;
}
}
if(IsAPlane(result) || IsABike(result) || IsAOBike(result) || IsABoat(result) || IsAPizzabike(result) || IsABus(result) || IsATowcar(result) || IsAHarvest(result) || IsADrugHarvest(result) || IsASweeper(result) || result >=78 && result <= 83 || GetVehicleModel(GetPlayerVehicleID(result)) == 523)
{
SendClientMessage(playerid, COLOR_GREY, " This vehicle doesn't have the trunk !");
return 1;
}
if(vehTrunkCounter[result] != 0)
{
ReduceTime[playerid] = 1;
SetTimerEx("ReduceTimer", 3000, false, "i", playerid);
new buffer[128];
new gunName[100];
SafeGivePlayerWeapon(playerid, vehTrunk[result][vehTrunkCounter[result]], vehTrunkAmmo[result][vehTrunkCounter[result]]);
GetWeaponName(vehTrunk[result][vehTrunkCounter[result]], gunName, sizeof(gunName));
format(buffer, sizeof(buffer), "You've taken a %s (Ammo: %i) from the vehicle.", gunName, vehTrunkAmmo[result][vehTrunkCounter[result]]);
SendClientMessage(playerid, COLOR_WHITE, buffer);
vehTrunk[result][vehTrunkCounter[result]] = '\0';
vehTrunkAmmo[result][vehTrunkCounter[result]] = '\0';
vehTrunkCounter[result]--;
format(string, sizeof(string), "* %s opens car's trunk and takes a weapon.", sendername);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
SaveTrunk();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Trunk is empty ! ");
return 1;
}
}
default:
{
SendClientMessage(playerid, COLOR_GREY, " Found more then one car in range");
return 1;
}
}
return 1;
}
else if(strcmp(x_nr,"putarmour",true) == 0)
{
new counter = 0;
new result;
new plyName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
for(new i; i != MAX_VEHICLES; i++)
{
new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, COLOR_GREY, " No cars with trunk near you");
return 1;
}
case 1:
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You can't open the trunk while you're in the car");
return 1;
}
if(IsAnOwnableCar(result))
{
if(PlayerInfo[playerid][pPcarkey] == result) { }
else if(PlayerInfo[playerid][pPcarkey2] == result) { }
else
{
SendClientMessage(playerid, COLOR_GREY, " Trunk is locked !");
return 1;
}
}
if(IsAPlane(result) || IsABike(result) || IsAOBike(result) || IsABoat(result) || IsAPizzabike(result) || IsABus(result) || IsATowcar(result) || IsAHarvest(result) || IsADrugHarvest(result) || IsASweeper(result) || result >=78 && result <= 83 || GetVehicleModel(GetPlayerVehicleID(result)) == 523)
{
SendClientMessage(playerid, COLOR_GREY, " This vehicle doesn't have the trunk !");
return 1;
}
new Float:plyArmour;
GetPlayerArmour(playerid, plyArmour);
if(plyArmour != 0)
{
SafeSetPlayerArmour(playerid, 0);
vehTrunkArmour[result] = plyArmour;
format(string, sizeof(string), "* %s takes off his/her body armour and puts it into car trunk.", sendername);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
SaveTrunk();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You haven't got any armour ");
return 1;
}
}
default:
{
SendClientMessage(playerid, COLOR_GREY, " Found more then one car in range");
return 1;
}
}
return 1;
}
else if(strcmp(x_nr,"takearmour",true) == 0)
{
new counter = 0;
new result;
new plyName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
for(new i; i != MAX_VEHICLES; i++)
{
new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, COLOR_GREY, " No cars with trunk near you");
return 1;
}
case 1:
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You can't open the trunk while you're in the car");
return 1;
}
if(IsAnOwnableCar(result))
{
if(PlayerInfo[playerid][pPcarkey] == result) { }
else if(PlayerInfo[playerid][pPcarkey2] == result) { }
else
{
SendClientMessage(playerid, COLOR_GREY, " Trunk is locked !");
return 1;
}
}
if(IsAPlane(result) || IsABike(result) || IsAOBike(result) || IsABoat(result) || IsAPizzabike(result) || IsABus(result) || IsATowcar(result) || IsAHarvest(result) || IsADrugHarvest(result) || IsASweeper(result) || result >=78 && result <= 83 || GetVehicleModel(GetPlayerVehicleID(result)) == 523)
{
SendClientMessage(playerid, COLOR_GREY, " This vehicle doesn't have the trunk !");
return 1;
}
if(vehTrunkArmour[result] != 0)
{
SafeSetPlayerArmour(playerid, vehTrunkArmour[result]);
vehTrunkArmour[result] = 0;
format(string, sizeof(string), "* %s takes out the body armour from the trunk and puts it on.", sendername);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
SaveTrunk();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " There are no body armour in the trunk ! ");
return 1;
}
}
default:
{
SendClientMessage(playerid, COLOR_GREY, " Found more then one car in range");
return 1;
}
}
return 1;
}
else if(strcmp(x_nr,"frisk",true) == 0)
{
if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2)
{
new counter = 0;
new result;
new plyName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
for(new i; i != MAX_VEHICLES; i++)
{
new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, COLOR_GREY, " No cars with trunk near you");
}
case 1:
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You can't open the trunk while you're in the car");
return 1;
}
if(IsAPlane(result) || IsABike(result) || IsAOBike(result) || IsABoat(result) || IsAPizzabike(result) || IsABus(result) || IsATowcar(result) || IsAHarvest(result) || IsADrugHarvest(result) || IsASweeper(result) || result >=78 && result <= 83 || GetVehicleModel(GetPlayerVehicleID(result)) == 523)
{
SendClientMessage(playerid, COLOR_GREY, " This vehicle doesn't have the trunk !");
return 1;
}
SendClientMessage(playerid, COLOR_LIGHT_BLUE, "|_______ Vehicle Trunk _______|");
for(new slot = 1; slot != MAX_TRUNK_SLOTS; slot++)
{
new gunname[100];
if(vehTrunk[result][slot] != 0)
{
GetWeaponName(vehTrunk[result][slot], gunname, sizeof(gunname));
format(string, sizeof(string), "| Slot %i: %s (Ammo: %i)", slot, gunname, vehTrunkAmmo[result][slot]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else
{
format(string, sizeof(string), "| Slot %i: Empty (Ammo: N/A)", slot);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
format(string, sizeof(string), "| Body armour: %f%", vehTrunkArmour[result]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s opens the trunk and checks what is inside.", sendername);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
return 1;
}
default:
{
SendClientMessage(playerid, COLOR_GREY, " Found more then one car in range");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You're not the cop ! ");
return 1;
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: /trunk [name]");
SendClientMessage(playerid, COLOR_WHITE, "Available names: info, putgun, takegun, putarmour, takearmour");
if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 2)
{
SendClientMessage(playerid, COLOR_WHITE, "You can /trunk frisk as a cop");
}
return 1;
}
}
return 1;
}
pawn Код:
public SaveTrunk()
{
new idx;
new File: file2;
idx = 184;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%i,%i,%i,%i,%i,%i,%i,%i,%i,%f\n",
vehTrunk[idx][1],
vehTrunkAmmo[idx][1],
vehTrunk[idx][2],
vehTrunkAmmo[idx][2],
vehTrunk[idx][3],
vehTrunkAmmo[idx][3],
vehTrunk[idx][4],
vehTrunkAmmo[idx][4],
vehTrunkCounter[idx],
vehTrunkArmour[idx]);
if(idx == 1)
{
file2 = fopen("LARP/Trunks/trunk.cfg", io_write);
}
else
{
file2 = fopen("LARP/Trunks/trunk.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
public LoadTrunk()
{
new arrCoords[13][64];
new strFromFile2[256];
new File: file = fopen("LARP/Trunks/trunk.cfg", io_read);
if (file)
{
new idx = 184;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
vehTrunk[idx][1] = strval(arrCoords[0]);
vehTrunkAmmo[idx][1] = strval(arrCoords[1]);
vehTrunk[idx][2] = strval(arrCoords[2]);
vehTrunkAmmo[idx][2] = strval(arrCoords[3]);
vehTrunk[idx][3] = strval(arrCoords[4]);
vehTrunkAmmo[idx][3] = strval(arrCoords[5]);
vehTrunk[idx][4] = strval(arrCoords[6]);
vehTrunkAmmo[idx][4] = strval(arrCoords[7]);
vehTrunkCounter[idx] = strval(arrCoords[8]);
vehTrunkArmour[idx] = floatstr(arrCoords[9]);
idx++;
}
}
return 1;
}
the errors :
Код:
C:\Users\WaiM Anaas\Documents\Downloads\Compressed\SAMP 2012\gamemodes\TW2.pwn(1511) : error 047: array sizes do not match, or destination array is too small C:\Users\WaiM Anaas\Documents\Downloads\Compressed\SAMP 2012\gamemodes\TW2.pwn(1516) : error 017: undefined symbol "PlayerInfo" C:\Users\WaiM Anaas\Documents\Downloads\Compressed\SAMP 2012\gamemodes\TW2.pwn(1516) : warning 215: expression has no effect C:\Users\WaiM Anaas\Documents\Downloads\Compressed\SAMP 2012\gamemodes\TW2.pwn(1516) : error 001: expected token: ";", but found "]" C:\Users\WaiM Anaas\Documents\Downloads\Compressed\SAMP 2012\gamemodes\TW2.pwn(1516) : error 029: invalid expression, assumed zero C:\Users\WaiM Anaas\Documents\Downloads\Compressed\SAMP 2012\gamemodes\TW2.pwn(1516) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 5 Errors.