22.04.2011, 03:57
(
Последний раз редактировалось sciman001; 22.04.2011 в 15:58.
Причина: updated code! AGAIN!!! REPLY ASAP!!!!! SUUPER URGENT!!!
)
Ok peoples.. i am developing a stats saving system in my gm and um.. well... djson is being an asshole... it saves one person to a .fson file and the rest is just file. code:
i also got this error from the updated code... what to do?
This is a bit of a problem.. and i really need this thing to work... so can someone like.. PLEASE HELP ME!!! AS IN, REPLY ASAP!!!! THIS IS SUUUUUUUUUUUUPER URGENT!!!!! THX... if u reply.
pawn Код:
#include <a_samp>
#include "../include/gl_common.inc"
#include <djson>
forward spec(playerid);
new gSpectateID[MAX_PLAYERS];
new total_vehicles_from_files = 0;
new pTeam[MAX_PLAYERS];
new mt;
new pRank[MAX_PLAYERS];
#define TEAM_GANG 0
#define TEAM_ARMY 1
#define CONFIGFILE "config/config.json"
#define USERFILE "Users/%s.json"
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_BROWN 0x993300AA
#define COLOR_ORANGE 0xFF9933AA
#define COLOR_CYAN 0x99FFFFAA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_BLACK 0x2C2727AA
#define COLOR_LIGHTCYAN 0xAAFFCC33
#define COLOR_LEMON 0xDDDD2357
#define COLOR_AQUA 0x7CFC00AA
#define COLOR_WHITEYELLOW 0xFFE87DFF
#define COLOR_BLUEAQUA 0x7E60FFFF
#define COLOR_DARKBLUE 0x15005EFF
#define COLOR_ALIEN 0x90FF87FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_LIGHTBLUE 0x00D0F6AA
#define COLOR_PURPLE 0xA600F6AA
#define COLOR_TUT 0xF6C861AA
#define COLOR_ROYAL 0x00C1F6AA
#define COLOR_CWHITE 0xE0FFFFAA
#define COLOR_INVISIBLE 0xFFFFFF00
#define RANK_NEWBIE 0
#define RANK_BABY_KILLA 1
#define RANK_SOLDIER 2
#define RANK_GANGSTA 3
#define RANK_UNDERBOSS 4
#define RANK_BOSS 5
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define AWII djInt(CONFIGFILE, "anticheat/AWII")
#define AM djInt(CONFIGFILE, "anticheat/AM")
#define AJP djInt(CONFIGFILE, "anticheat/AJP")
#define WEATHER djInt(CONFIGFILE, "sstats/WEATHER")
#if !defined SetPVarInt
#error Version 0.3 R7 or higher of SA:MP Server requiered
#endif
main()
{
print("WW7 LOADED!");
}
public OnGameModeInit()
{
AddPlayerClass(121,-1.0312,2.4693,3.1172,339.1827,0,0,0,0,0,0); //0
AddPlayerClass(285,-1.0312,2.4693,3.1172,339.1827,0,0,0,0,0,0); //1
SendRconCommand("mapname WAR");
AddStaticPickup(344, 2, 198.8556, 1931.6708, 23.2422, -1); //gun1-1
AddStaticPickup(356, 2, 203.6221, 1932.8588, 23.2422, -1); //gun2-2
AddStaticPickup(361, 2, 207.3351, 1929.3782, 23.2422, -1); //gun3-3
AddStaticPickup(349, 2, 214.8471, 1930.9595, 22.2422, -1); //gun4-4
SetGameModeText("TDM/DM");
mt = CreateObject(18752, 6.4429, 1973.8485, 15.6406, 0, 0, 0, 500);
Create3DTextLabel( "MOUNT NIPPLEZ", 0x33AA33AA, 27.1356, 1957.3918, 77.0658, 400.0, 0, 0 );
// OTHER AREAS
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
djson_GameModeInit();
printf("Server starts: %d",djInt("stats.json","server/started"));
printf("player spawns: %d",djInt("stats.json","players/spawed"));
printf("player deaths: %d",djInt("stats.json","players/died"));
djStyled(true);
printf("Total vehicles from files: %d",total_vehicles_from_files);
if(!fexist(CONFIGFILE))
{
djAutocommit(false);
djCreateFile (CONFIGFILE);
djSetInt(CONFIGFILE,"anticheat/AWII", 1);
djSetInt(CONFIGFILE,"anticheat/AM", 1);
djSetInt(CONFIGFILE,"anticheat/AJP", 1);
djSetInt(CONFIGFILE,"sstats/WEATHER", 77);
djCommit(CONFIGFILE);
djAutocommit(true);
}
SetWeather(WEATHER);
print(" ");
print(" (__) ");
print(" (oo) ");
print(" /------\\/ ");
print(" / | || ");
print("* /\\-----/\\ ");
print(" ");
return 1;
}
public OnGameModeExit()
{
DestroyObject(mt);
djson_GameModeExit();
return 1;
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, COLOR_GREEN, "PLEASE USE /help FOR SOME SERVER INFO AND COMMANDS");
SetPlayerWorldBounds(playerid, 478.7929, -490.4708, 2183.763, 1226.177);
UsePlayerPedAnims();
new pname[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), USERFILE, pname);
new ip[24];
GetPlayerIp(playerid, ip, sizeof(ip));
if(!fexist(str))
{
djAutocommit(false);
djCreateFile (str);
djSet(str,"player/NAME", pname);
djSetInt(str,"player/RANK", pRank[playerid]);
djSetInt(str,"player/SCORE",GetPlayerScore(playerid));
djSetInt(str,"player/CASH",GetPlayerMoney(playerid));
djSet(str,"player/IP", ip);
djCommit(str);
djAutocommit(true);
}
else
{
new ip2[24];
GetPlayerIp(playerid, ip2, sizeof(ip2));
if(ip2 == dj(str, "IP"))
{
SetPlayerScore(playerid, djInt(str, "player/SCORE"));
pRank[playerid] = djInt(str, "player/RANK");
GivePlayerMoney(playerid, djInt(str, "player/CASH"));
}
else
{
new string[128];
format(string, sizeof(string), "YOU ARENT THE REAL %s! GTFO!!!", pname);
SendClientMessage(playerid, COLOR_RED, string);
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new pname[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), USERFILE, pname);
if(fexist(str))
{
djAutocommit(false);
djSet(str,"player/NAME", pname);
djSetInt(str,"player/RANK", pRank[playerid]);
djSetInt(str,"player/SCORE",GetPlayerScore(playerid));
djSetInt(str,"player/CASH",GetPlayerMoney(playerid));
djCommit(str);
djAutocommit(true);
}
SetPlayerScore(playerid, 0);
pRank[playerid] = 0;
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetupPlayerForClassSelection(playerid);
SetPlayerTeamFromClass(playerid, classid);
SetPlayerTextFromClass(playerid, classid);
return 1;
}
public OnPlayerSpawn(playerid)
{
if(pTeam[playerid] == TEAM_GANG)
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 30.2116,1958.4891,77.8821);
GivePlayerWeapon(playerid, 23, 9999999);
GivePlayerWeapon(playerid, 26, 9999999);
GivePlayerWeapon(playerid, 28, 9999999);
GivePlayerWeapon(playerid, 30, 9999999);
SetPlayerColor(playerid, COLOR_RED);
SendClientMessage(playerid, COLOR_YELLOW, "Go attack the blues in area 51!");
}
else if(pTeam[playerid] == TEAM_ARMY)
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 204.7200,1909.8882,17.6406);
GivePlayerWeapon(playerid, 17, 9999999);
GivePlayerWeapon(playerid, 29, 9999999);
GivePlayerWeapon(playerid, 27, 9999999);
GivePlayerWeapon(playerid, 34, 9999999);
GivePlayerWeapon(playerid, 4, 9999999);
GivePlayerWeapon(playerid, 31, 9999999);
SetPlayerColor(playerid, COLOR_BLUE);
SendClientMessage(playerid, COLOR_YELLOW, "Defend yourselvs from the reds, and dont leave area 51!");
}
SetPlayerAttachedObject(playerid,1 , 356, 1,0,-0.18,0,0,30,0);
SetPlayerAttachedObject(playerid,2 , 355, 1,0,-0.14,-0.1,0,-30,0);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
SendClientMessage(killerid, COLOR_GREEN, "You got +$50 money and +1 score for killing an enemy!");
GivePlayerMoney(killerid,50);
GivePlayerMoney(playerid,-50);
SendClientMessage(playerid, COLOR_RED, "You lost -$50 money for dying!");
TogglePlayerSpectating(playerid, true);
PlayerSpectatePlayer(playerid, killerid);
gSpectateID[playerid] = playerid;
SetTimerEx("spec", 7500, false, "i", playerid);
new string[256];
if(GetPlayerScore(killerid) == 5) // Amount of required kills to get rank 1 *Baby Killa'*
{
GetPlayerName(killerid, string, sizeof(string) );
format(string, sizeof(string), ">> %s advanced to rank *Baby Killa'* by killing %d players", string, GetPlayerScore(killerid) );
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, 5000);
pRank[playerid] = 1;
}
else if(GetPlayerScore(killerid) == 25) // Amount of required kills to get rank 2 *Soldier*
{
GetPlayerName(killerid, string, sizeof(string) );
format(string, sizeof(string), ">> %s advanced to rank *Soldier* by killing %d players", string, GetPlayerScore(killerid));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, 5000);
pRank[playerid] = 2;
}
else if(GetPlayerScore(killerid) == 50) // Amount of required kills to get rank 3 *Gangsta'*
{
GetPlayerName(killerid, string, sizeof(string) );
format(string, sizeof(string), ">> %s advanced to rank *Gangsta'* by killing %d players", string, GetPlayerScore(killerid));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, 5000);
pRank[playerid] = 3;
}
else if(GetPlayerScore(killerid) == 150) // Amount of required kills to get rank 4 *Underboss*
{
GetPlayerName(killerid, string, sizeof(string) );
format(string, sizeof(string), ">> %s advanced to rank *UnderBoss* by killing %d players", string, GetPlayerScore(killerid));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, 5000);
pRank[playerid] = 4;
}
else if(GetPlayerScore(killerid) == 300) // Amount of required kills to get rank 5 *Tha' Boss*
{
GetPlayerName(killerid, string, sizeof(string) );
format(string, sizeof(string), ">> %s advanced to rank *The Boss* by killing %d players", string, GetPlayerScore(killerid));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, 5000);
pRank[playerid] = 5;
}
return 1;
}
public OnPlayerUpdate(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
if(AWII == 1)
{
if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
SetPlayerArmedWeapon(playerid,0); // fists
return 0; // no syncing until they change their weapon
}
}
if(AM == 1)
{
if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN) {
Kick(playerid);
return 0;
}
}
if(AJP == 1)
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) {
Kick(playerid);
return 0;
}
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == '#')
{
new name[24], string[256];GetPlayerName(playerid, name, 24);
format(string, sizeof(string), "[TEAM]%s: %s", name, text[1]);
for(new c = 0; c < MAX_PLAYERS; c++)
{
if(IsPlayerConnected(c))
{
if(GetPlayerTeam(c) == GetPlayerTeam(playerid))
{
SendClientMessage(c, COLOR_RED, string);
}
}
return 0;
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(help, 4, cmdtext); //all
dcmd(kill, 4, cmdtext); //all
dcmd(para, 4, cmdtext); //all
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid)
{
SetPlayerArmedWeapon(playerid, 0);
}
public spec(playerid)
{
TogglePlayerSpectating(gSpectateID[playerid], 0);
return 1;
}
dcmd_help(playerid, params[])
{
#pragma unused params
SCM(playerid, COLOR_RED, "[COMMANDS]: /kill /help /para");
SCM(playerid, COLOR_RED, "This server is about %%8 done.");
return 1; // the cmd will work for admins level 1 or over
}
dcmd_para(playerid, params[])
{
#pragma unused params
SendClientMessage(playerid, COLOR_RED, "You are parachuting!");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
GivePlayerWeapon(playerid, 46, 1);
SetPlayerPos(playerid, x, y, z+500);
return 1;
}
dcmd_kill(playerid, params[])
{
#pragma unused params
SetPlayerHealth(playerid, 0);
SCM(playerid, COLOR_RED, "You commited suicide!");
return 1; // the cmd will work for admins level 1 or over
}
stock SCM(playerid, color, string[])
{
SendClientMessage(playerid, color, string);
return 1;
}
stock SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
pTeam[playerid] = TEAM_GANG;
return 1;
}
else if(classid == 1)
{
pTeam[playerid] = TEAM_ARMY;
return 1;
}
return 1;
}
stock SetPlayerTextFromClass(playerid, classid)
{
if(classid == 0)
{
GameTextForPlayer(playerid, "]GANG]", 750, 4);
return 1;
}
else if(classid == 1)
{
GameTextForPlayer(playerid, "]ARMY]", 750, 4);
return 1;
}
return 1;
}
stock SetupPlayerForClassSelection(playerid)
{
SetPlayerInterior(playerid,9);
SetPlayerFacingAngle(playerid,0.0);
SetPlayerPos(playerid,315.7802,972.0253,1961.8705);
SetPlayerCameraPos(playerid,315.7802,975.0253,1961.8705);
SetPlayerCameraLookAt(playerid,315.7802,972.0253,1961.8705);
return 1;
}
pawn Код:
E:\ww7\gamemodes\WW7.pwn(133) : error 033: array must be indexed (variable "ip2")