Kann gar nicht, denn würde man das jetzt so im Script einbauen, würde man den Error "undefined Symbol i" bekommen.
Dazu fehlt die Enum Deklaration
upps, sry habe das sehr schnell erstellt und bei mir einfach automatisch richtig eingebaut (der Timer ist bei mir wo anders drinne)
Hier jedenfalls der richtige Code:
#include <a_samp>
#define dcmd(%1,%2,%3) if(!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
forward Timer();
forward Float:GetDistanceBetweenPlayers(p1,p2);
#define AnwaltPos 1778.1670, -1663.6190, 14.4359 //Anwälte müssen, um die Verhandlung am Laufen zu halten an dieser Position sein
#define AnwaltMark 8 //Größe des Markers (wird auf AnwaltPos gesetzt)
#define AnwaltEntf 15.0 //Maximaler Abstand zu AnwaltPos (wenn weiter weg läuft die Zeit nicht weiter ab)
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_GREY 0xAFAFAFAA
enum pInfo
{
pLawSkill,
freeUser,
freeUserID,
freeUserTime,
freeUserPrice,
pJailTime,
pJob,
pPnumber,
pJailed
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnGameModeInit()
{
SetTimer("Timer", 5000, 1);
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pLawSkill] = 0;
PlayerInfo[playerid][freeUser] = -1;
PlayerInfo[playerid][freeUserID] = -1;
PlayerInfo[playerid][freeUserTime] = -1;
PlayerInfo[playerid][freeUserPrice] = -1;
return 1;
}
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:xx1,Float:yy1,Float:zz1,Float:xx2,Float:yy2,Float:zz2;
if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,xx1,yy1,zz1);
GetPlayerPos(p2,xx2,yy2,zz2);
return floatsqroot(floatpower(floatabs(floatsub(xx2,xx1)),2)+floatpower(floatabs(floatsub(yy2,yy1)),2)+floatpower(floatabs(floatsub(zz2,zz1)),2));
}
public Timer()
{
new string[256];
for(new i; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][freeUserID] != -1)
{
if(!IsPlayerConnected(PlayerInfo[i][freeUserID]))
{
SendClientMessage(i,COLOR_RED,"Dein Mandant hat sich ausgeloggt!");
PlayerInfo[i][freeUserID] = -1;
PlayerInfo[i][freeUserTime] = -1;
PlayerInfo[i][freeUserPrice] = -1;
DisablePlayerCheckpoint(i);
}
else
{
if(IsPlayerInRangeOfPoint(i, AnwaltEntf, AnwaltPos))
{
if(PlayerInfo[i][freeUserTime] > 0)
{
PlayerInfo[i][freeUserTime] -= 5;
}
else if(PlayerInfo[i][freeUserTime] <= 0)
{
new pName[32], pIdName[32];
GetPlayerName(i, pName, sizeof(pName));
GetPlayerName(PlayerInfo[i][freeUserID], pIdName, sizeof(pIdName));
format(string, sizeof(string), "Du hast %s für $%d aus dem Gefängnis geholt!", pIdName, PlayerInfo[i][freeUserPrice]);
SendClientMessage(i,COLOR_RED,string);
format(string, sizeof(string), "%s hat dich für $%d aus dem gefängnis geholt!", pName, PlayerInfo[i][freeUserPrice]);
SendClientMessage(PlayerInfo[i][freeUserID],COLOR_RED,string);
GivePlayerMoney(i, -PlayerInfo[i][freeUserPrice]);
PlayerInfo[PlayerInfo[i][freeUserID]][pJailTime] = 0;
PlayerInfo[i][freeUserID] = -1;
PlayerInfo[i][freeUserTime] = -1;
PlayerInfo[i][freeUserPrice] = -1;
PlayerInfo[i][pLawSkill] += 1;
DisablePlayerCheckpoint(i);
}
}
}
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(free,4,cmdtext);
//--------------------------- ANWALT -------------------------------------------------
if(strcmp(cmdtext,"/anwaelte",true)==0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COLOR_GREEN, "______________ Online Anwälte ______________");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pJob] == 20)
{
new sendername[MAX_PLAYER_NAME], string[256];
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Name: %s ID: %d Skill: %d Tel: %d", sendername, i, PlayerInfo[i][pLawSkill], PlayerInfo[i][pPnumber]);
SendClientMessage(playerid, COLOR_GREY, string);
}
}
}
}
return 1;
}
return 1;
}
//------------------------------------ [ANWALT] ----------------------------------------
dcmd_free(playerid,params[])
{
new pID;
new string[256];
new pName[MAX_PLAYER_NAME],pIdName[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pJob] != 20) { return SendClientMessage(playerid,0xAFAFAFAA,"Du bist kein Anwalt!"); }
if(sscanf(params,"u",pID)) { return SendClientMessage(playerid,0xAFAFAFAA,"benutze: /free [playerid]"); }
if(!IsPlayerConnected(pID)) { return SendClientMessage(playerid,COLOR_RED,"Ungültige ID!"); }
if(PlayerInfo[pID][pJailed] == 0) { return SendClientMessage(playerid,COLOR_RED,"Dieser Spieler befindet sich nicht im Gefängnis!"); }
if(GetDistanceBetweenPlayers(playerid,pID) > 10.0) { return SendClientMessage(playerid,COLOR_GREY,"Du bist zu weit entfernt!"); }
new skill;
new level = PlayerInfo[playerid][pLawSkill];
if(level >= 0 && level <= 50) { skill = 1;}
else if(level >= 51 && level <= 100) { skill = 2; }
else if(level >= 101 && level <= 200) { skill = 3; }
else if(level >= 201 && level <= 400) { skill = 4; }
else if(level >= 401) { skill = 5; }
new price = PlayerInfo[pID][pJailTime]*20;
new ftime;
if(skill == 1)
{
ftime = PlayerInfo[pID][pJailTime]/10*8;
}
else if(skill == 2)
{
ftime = PlayerInfo[pID][pJailTime]/10*7;
}
else if(skill == 3)
{
ftime = PlayerInfo[pID][pJailTime]/10*6;
}
else if(skill == 4)
{
ftime = PlayerInfo[pID][pJailTime]/10*5;
}
else if(skill == 5)
{
ftime = PlayerInfo[pID][pJailTime]/10*3;
}
else
{
ftime = PlayerInfo[pID][pJailTime]/10*6;
}
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(pID, pIdName, sizeof(pIdName));
if(PlayerInfo[playerid][freeUser] == pID)
{
PlayerInfo[playerid][freeUserID] = pID;
PlayerInfo[playerid][freeUserTime] = ftime;
PlayerInfo[playerid][freeUserPrice] = price;
format(string, sizeof(string), "Du hast %s's Fall angenommen! Bitte begebe dich zum Checkpoint!", pName);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s hat deinen Fall angenommen. Kosten: %d - Dauer: ~%d", pName, price, ftime);
SendClientMessage(PlayerInfo[playerid][freeUser], COLOR_LIGHTBLUE, string);
SetPlayerCheckpoint(playerid, AnwaltPos, AnwaltMark);
}
else
{
format(string, sizeof(string), "%s würde dich %d kosten und dauert etwa %dSekunden. Gib /free %d erneut ein, um den Fall anzunehmen!", pName, price, ftime, pID);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s hat sich deinen fall angesehen. Kosten: %d - Dauer: %d Sekunden", pName, price, ftime);
SendClientMessage(PlayerInfo[playerid][freeUser], COLOR_LIGHTBLUE, string);
PlayerInfo[playerid][freeUser] = pID;
}
return 1;
}
stock sscanf(string[], format[], {Float,_}:...)
{
#if defined isnull
if(isnull(string))
#else
if(string[0] == 0 || (string[0] == 1 && string[1] == 0))
#endif
{
return format[0];
}
#pragma tabsize 4
new
formatPos = 0,
stringPos = 0,
paramPos = 2,
paramCount = numargs(),
delim = ' ';
while (string[stringPos] && string[stringPos] <= ' ')
{
stringPos++;
}
while (paramPos < paramCount && string[stringPos])
{
switch (format[formatPos++])
{
case '\0':
{
return 0;
}
case 'i', 'd':
{
new
neg = 1,
num = 0,
ch = string[stringPos];
if(ch == '-')
{
neg = -1;
ch = string[++stringPos];
}
do
{
stringPos++;
if('0' <= ch <= '9')
{
num = (num * 10) + (ch - '0');
}
else
{
return -1;
}
}
while ((ch = string[stringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num * neg);
}
case 'h', 'x':
{
new
num = 0,
ch = string[stringPos];
do
{
stringPos++;
switch (ch)
{
case 'x', 'X':
{
num = 0;
continue;
}
case '0' .. '9':
{
num = (num << 4) | (ch - '0');
}
case 'a' .. 'f':
{
num = (num << 4) | (ch - ('a' - 10));
}
case 'A' .. 'F':
{
num = (num << 4) | (ch - ('A' - 10));
}
default:
{
return -1;
}
}
}
while ((ch = string[stringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num);
}
case 'c':
{
setarg(paramPos, 0, string[stringPos++]);
}
case 'f':
{
new changestr[16], changepos = 0, strpos = stringPos;
while(changepos < 16 && string[strpos] && string[strpos] != delim)
{
changestr[changepos++] = string[strpos++];
}
changestr[changepos] = '\0';
setarg(paramPos,0,_:floatstr(changestr));
}
case 'p':
{
delim = format[formatPos++];
continue;
}
case '\'':
{
new
end = formatPos - 1,
ch;
while ((ch = format[++end]) && ch != '\'') {}
if(!ch)
{
return -1;
}
format[end] = '\0';
if((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
{
if(format[end + 1])
{
return -1;
}
return 0;
}
format[end] = '\'';
stringPos = ch + (end - formatPos);
formatPos = end + 1;
}
case 'u':
{
new
end = stringPos - 1,
id = 0,
bool:num = true,
ch;
while ((ch = string[++end]) && ch != delim)
{
if(num)
{
if('0' <= ch <= '9')
{
id = (id * 10) + (ch - '0');
}
else
{
num = false;
}
}
}
if(num && IsPlayerConnected(id))
{
setarg(paramPos, 0, id);
}
else
{
#if !defined foreach
#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if(IsPlayerConnected(%2))
#define __SSCANF_FOREACH__
#endif
string[end] = '\0';
num = false;
new
name[MAX_PLAYER_NAME];
id = end - stringPos;
foreach (Player, playerid)
{
GetPlayerName(playerid, name, sizeof (name));
if(!strcmp(name, string[stringPos], true, id))
{
setarg(paramPos, 0, playerid);
num = true;
break;
}
}
if(!num)
{
setarg(paramPos, 0, INVALID_PLAYER_ID);
}
string[end] = ch;
#if defined __SSCANF_FOREACH__
#undef foreach
#undef __SSCANF_FOREACH__
#endif
}
stringPos = end;
}
case 's', 'z':
{
new
i = 0,
ch;
if(format[formatPos])
{
while ((ch = string[stringPos++]) && ch != delim)
{
setarg(paramPos, i++, ch);
}
if(!i)
{
return -1;
}
}
else
{
while ((ch = string[stringPos++]))
{
setarg(paramPos, i++, ch);
}
}
stringPos--;
setarg(paramPos, i, '\0');
}
default:
{
continue;
}
}
while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
{
stringPos++;
}
while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
{
stringPos++;
}
paramPos++;
}
do
{
if((delim = format[formatPos++]) > ' ')
{
if(delim == '\'')
{
while ((delim = format[formatPos++]) && delim != '\'') {}
}
else if(delim != 'z')
{
return delim;
}
}
}
while (delim > ' ');
return 0;
}
0 Errors, 0 Warnungen
Kompilierung erfolgreich
PWNMod Compiler Version 1.2
(c) Trooper[Y]
In Kooperation mit GTA-Servers.de