[AJUDA]Operador!
#1

Код:
enum pInfo
{
    pOperador
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Quero criar um comando que de operador para a pessoa !
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=277842
Reply
#3

pawn Код:
command(daroperador, playerid, params[])
{
   new id, operador;
   if(sscanf(params, "di", id, operador)) return SendClientMessage(playerid, -1, "/daroperador id operador");
   if(!IsPlayerConnected(id) || id == -1) return SendClientMessage(playerid, -1, "Jogador invбlido");
   PlayerInfo[id][pOperador] = operador;
   SendClientMessage(id, "Lhe deram operador!");
   SendClientMessage(id, "Vocк deu operador pro cara.!"); return 1;
}
Reply
#4

command(daroperador, playerid, params[])
{
new id, operador;
if(sscanf(params, "di", id, operador)) return SendClientMessage(playerid, -1, "/daroperador id operador");
if(!IsPlayerConnected(id) || id == -1) return SendClientMessage(playerid, -1, "Jogador invбlido");
PlayerInfo[id][pOperador] = operador;
SendClientMessage(id, "Lhe deram operador!");
SendClientMessage(playerid, "Vocк deu operador pro cara.!"); return 1;
}
Reply
#5

========@Garfield============
Nao Entendi muito Garfield ...
===========
@Ricop522
Tem como criar pra min apartir de :

if(strcmp(cmd, "/daroperador", true) == 0)

(Somente AdminsRCON podem dar !)
Reply
#6

pawn Код:
if(!strcmp(cmd, "/daroperador", true)) {
    if(!IsPlayerAdmin(playerid)) return 1;
    tmp = strtok(cmdtext, idx);
    new id = strval(tmp);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "/daroperador id operador");
    tmp = strtok(cmdtext, idx);
    new op = strval(tmp);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "/daroperador id operador");
    PlayerInfo[id][pOperador] = op;
    SendClientMessage(id, -1, "Te deram operador ");
    SendClientMessage(playerid, -1, "Vc deu operador pro cara rsrrrs vida loka dorgas");
    return 1;
}
Reply
#7

Код:
 error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1734) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1735) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1736) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1737) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1738) : error 017: undefined symbol "tmp"
Reply
#8

@gcoder Aconselho a usar sscanf do q strtok sscanf й bem mais simples e nгo disperdissa Cйlulas agora o strtok Disperdissa mta Cйlulas

Coloque isto no final do gm. (sу se vc for usar strtok agora se for usar sscanf nao й necessбrio)
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Tenta assim:

pawn Код:
if(!strcmp(cmd, "/daroperador", true))
{
    new tmp[30];
    if(!IsPlayerAdmin(playerid)) return 1;
    tmp = strtok(cmdtext, idx);
    new id = strval(tmp);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "/daroperador id operador");
    tmp = strtok(cmdtext, idx);
    new op = strval(tmp);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "/daroperador id operador");
    PlayerInfo[id][pOperador] = op;
    SendClientMessage(id, -1, "Te deram operador ");
    SendClientMessage(playerid, -1, "Vc deu operador pro cara rsrrrs vida loka dorgas");
    return 1;
}
Reply
#9

@Caio_Frezze

Tipo o problema e que meu gm todo ja ta em strtok ai pra mudar fica foda

Eu Coloquei o Codigo que voce passo e nao mudo nada '-'
Код:
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1733) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1734) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1735) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1736) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1737) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1738) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(2032) : warning 202: number of arguments does not match definition
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(2506) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(2565) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(2566) : error 021: symbol already defined: "strtok"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
Reply
#10

Quote:
Originally Posted by gcoder
Посмотреть сообщение
Код:
 error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1734) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1735) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1736) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1737) : error 017: undefined symbol "tmp"
C:\Users\Gabriel\Downloads\samp03dsvr_R2_win32\gamemodes\GM1.pwn(1738) : error 017: undefined symbol "tmp"

pawn Код:
if(!strcmp(cmd, "/daroperador", true)) {
    if(!IsPlayerAdmin(playerid)) return 1;
    new tmp[128];
    tmp = strtok(cmdtext, idx);
    new id = strval(tmp);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "/daroperador id operador");
    tmp = strtok(cmdtext, idx);
    new op = strval(tmp);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "/daroperador id operador");
    PlayerInfo[id][pOperador] = op;
    SendClientMessage(id, -1, "Te deram operador ");
    SendClientMessage(playerid, -1, "Vc deu operador pro cara rsrrrs vida loka dorgas");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)