Pomoc u vezi "giveplayerid = ReturnUser(tmp)"

Započeo [CM] BrunoHP, Jul 28, 2010, 12:07:17 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Pozdrav, poceo sam raditi DM scriptu i kada sam htjeo ubaciti amin system, sve sam ok radio. Cim sam stavio "/kick" komandu javlja mi se error u vezi redu "giveplayerid = ReturnUser(tmp);". Prvo mi kaze kako ne postoji ReturnUser pa sam dodao na pocetku OnPlayerCommandText -> new ReturnUser . Evo kako izgleda ispod OPCT:

public OnPlayerCommandText(playerid, cmdtext[])
{
   new cmd[256];
   new string[256];
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid, idx;
new ReturnUser;
cmd = strtok(cmdtext, idx);
   cmd = strtok(cmdtext, idx);
new tmp[256];
   new playername[MAX_PLAYER_NAME];


Dalje su komande...

E, a ovako izgleda komanda kick preuzeta iz GF:[/b]

if(strcmp(cmd, "/kick", true) == 0)
{
   if(IsPlayerConnected(playerid))
   {
    tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "KORISTITE: /kick [ID/Ime] [razlog]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(PlayerInfo[playerid][pAdmin] >= 1)
{
if(IsPlayerConnected(giveplayerid))
{
   if(giveplayerid != INVALID_PLAYER_ID)
   {
   GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_WHITE, "KORISTITE: /kick [ID/Ime] [razlog]");
return 1;
}
new year, month,day;
getdate(year, month, day);
format(string, sizeof(string), "Admin %s je izbacio(kickao) igraca %s sa servera. Razlog: %s", sendername, giveplayer, (result));
KickLog(string);
format(string, sizeof(string), "Admin %s je izbacio(kickao) igraca %s sa servera. Razlog: %s", sendername, giveplayer, (result));
SendClientMessageToAll(COLOR_LIGHTRED, string);
Kick(giveplayerid);
return 1;
}
}
}
else
{
format(string, sizeof(string), "%d nije aktivan igrac.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}


I ovo je error koji se javlja u redu gdje se nalazi "giveplayerid = ReturnUser(tmp);":
C:\Documents and Settings\Laptop\Desktop\CroMafia\gamemodes\cmr.pwn(576) : warning 219: local variable "ReturnUser" shadows a variable at a preceding level
C:\Documents and Settings\Laptop\Desktop\CroMafia\gamemodes\cmr.pwn(771) : error 012: invalid function call, not a valid address
C:\Documents and Settings\Laptop\Desktop\CroMafia\gamemodes\cmr.pwn(771) : warning 215: expression has no effect
C:\Documents and Settings\Laptop\Desktop\CroMafia\gamemodes\cmr.pwn(771) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\Laptop\Desktop\CroMafia\gamemodes\cmr.pwn(771) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Laptop\Desktop\CroMafia\gamemodes\cmr.pwn(771) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Hvala unaprijed!


Poslednja Izmena: Jul 28, 2010, 12:07:39 POSLE PODNE od BrunoHP

Imas ReturnPlayer funkciju?

Ako nemas dodaj ju:

ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21) // Strip out leading spaces
{
if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos])) // Check whole passed string
{
// If they have a numeric name you have a problem (although names are checked on id failure)
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
{
/*if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "User not connected");
}*/
userid = INVALID_PLAYER_ID;
}
else
{
return userid; // A player was found
}
}
/*else
{
if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
}
userid = INVALID_PLAYER_ID;
}
return userid;*/
// Removed for fallthrough code
}
// They entered [part of] a name or the id search failed (check names just incase)
new len = strlen(text[pos]);
new count = 0;
new name[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof (name));
if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
{
if (len == strlen(name)) // Exact match
{
return i; // Return the exact player on an exact match
// Otherwise if there are two players:
// Me and MeYou any time you entered Me it would find both
// And never be able to return just Me's id
}
else // Partial match
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count)
{
SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
}
}
userid = INVALID_PLAYER_ID;
}
return userid; // INVALID_USER_ID for bad return
}


RESPECT 4 EVER: John, GLC,bAndzi, Nikola, Sop, Zoki, Bruno_Venuti, Mele, Luka P,ExtremePower,Wang(neki kineski frajer)

NAJBOLJI CITATI:
Citat: [GF]Alive poslato Jun 24, 2010, 18:20:19 POSLE PODNE
Paizte ljud mozda je KayLoger! ! !
MOJI RADOVI:
[FS]Trofeji


Bilo gdje u skripti samo ne u neki callback.


RESPECT 4 EVER: John, GLC,bAndzi, Nikola, Sop, Zoki, Bruno_Venuti, Mele, Luka P,ExtremePower,Wang(neki kineski frajer)

NAJBOLJI CITATI:
Citat: [GF]Alive poslato Jun 24, 2010, 18:20:19 POSLE PODNE
Paizte ljud mozda je KayLoger! ! !
MOJI RADOVI:
[FS]Trofeji

E sada sam popravio taj error ali mi se javlja drugi koji govori da ima negdje jos u scripti a nema nigdje osim "giveplayerid = ReturnUser(tmp) na /kick i ostalim komandama koje ih trebaju.
C:\Documents and Settings\Laptop\Desktop\CroMafia\gamemodes\cmr.pwn(95) : error 021: symbol already defined: "ReturnUser"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


6 Errors.

Poslednja Izmena: Jul 28, 2010, 13:41:47 POSLE PODNE od BrunoHP

Onda makni, daj molim te pricekaj da ti nekod rugi odgovori jer sam se proteklih 2h mucio s skriptom imam velikih problema i sva logika mi je otkazala u glavi.  :-[


EDIT: Samo izbrisi onu varijablu ReturnUser pod OnPlayerCommandText callbackom.
Poslednja Izmena: Jul 28, 2010, 23:04:22 POSLE PODNE od LordShigi


RESPECT 4 EVER: John, GLC,bAndzi, Nikola, Sop, Zoki, Bruno_Venuti, Mele, Luka P,ExtremePower,Wang(neki kineski frajer)

NAJBOLJI CITATI:
Citat: [GF]Alive poslato Jun 24, 2010, 18:20:19 POSLE PODNE
Paizte ljud mozda je KayLoger! ! !
MOJI RADOVI:
[FS]Trofeji

Bio sam to obrisao vec ali sam stavio tu ReturnUser funkciju na pocetak scripte odmah prije ovoga sto bude hrpa new i ispod definea. Sad nisam na svom laptopu pa ti mogu samo reci kako sam to stavio.

Fakat neznam... Mozda dok prespavam se sjetim necega.


RESPECT 4 EVER: John, GLC,bAndzi, Nikola, Sop, Zoki, Bruno_Venuti, Mele, Luka P,ExtremePower,Wang(neki kineski frajer)

NAJBOLJI CITATI:
Citat: [GF]Alive poslato Jun 24, 2010, 18:20:19 POSLE PODNE
Paizte ljud mozda je KayLoger! ! !
MOJI RADOVI:
[FS]Trofeji


ReturnUser je funkcija .. ovo "new ReturnUser;" ti netreba omg
Vikend je policija nas hvata,
vikend je ode cijela plata,
oko nas stvari ukradene,
sve smo dali na planove i sheme..
||||:=:=:=:=:=:=::=:=:=:=:=:=:=:THE IVEX:=:=:=:=:=:=:=:=:=::=:=:=:=:=:=::=:|||| 


PS: Ne saljite mi nikakve pm jer neodgovaram na njih! Ako trebate nes pitajte ove pr0 skriptere pa neka vam kazu!Hvala !

Fala vam na pomoci ali sam samo trebo dodat include "utils" i rjesen problem xD! Opet bez vase pomoci nebi se toga sjetio xD

Haha, omg, kako sam glup. Jednostavije nemoze biti.


RESPECT 4 EVER: John, GLC,bAndzi, Nikola, Sop, Zoki, Bruno_Venuti, Mele, Luka P,ExtremePower,Wang(neki kineski frajer)

NAJBOLJI CITATI:
Citat: [GF]Alive poslato Jun 24, 2010, 18:20:19 POSLE PODNE
Paizte ljud mozda je KayLoger! ! !
MOJI RADOVI:
[FS]Trofeji