new
Permissao[MAX_PLAYERS]
;
if(strcmp(cmdtext, "/darpermicaodragon", true) == 0)
{
new
PlayerID[24],
NomeADM[24],
Celula[124]
;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USE: /darpermicaodragon [ id ]");
new IDPlayer;
IDPlayer = ReturnUser(tmp);
if(!IsPlayerConnected(IDPlayer)) return SendClientMessage(playerid, -1, "ID Nгo conectado");
if(IDPlayer != INVALID_PLAYER_ID)
{
GetPlayerName(IDPlayer, PlayerID, sizeof(PlayerID));
GetPlayerName(playerid, NomeADM, sizeof(NomeADM));
Permissao[IDPlayer] = 1;
format(Celula, sizeof(Celula), "Vocк deu a permissгo ao player %s usar o /clandragonkit", PlayerID);
SendClientMessage(playerid, -1, Celula);
format(Celula, sizeof(Celula), "O Admin %s deu permissгo a vocк a usar o comando /clandragonkit", NomeADM);
SendClientMessage(IDPlayer, -1, Celula);
}
return true;
}
if(strcmp(cmdtext, "/clandragonkit", true) == 0)
{
if(Permissao[playerid] != 1) return SendClientMessage(playerid, -1, "Vocк nгo tem permissгo para usar esse comando. Peзa a um Admin !");
SendClientMessage(playerid, -1, "Vocк pegou o Dragon KIT !");
GivePlayerWeapon(playerid, 26/*Eagle*/, 500/*500 Balas*/); // ID da Arma, Balas...
Permissao[playerid] = 0;
// bota o resto das armas ai !
return true;
}
.pwn(2065) : error 017: undefined symbol "tmp" .pwn(2065) : error 017: undefined symbol "strtok" .pwn(2066) : error 017: undefined symbol "tmp" .pwn(2068) : error 017: undefined symbol "ReturnUser" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
linhas: 2065=tmp = strtok(cmdtext, idx); 2065=error 017: undefined symbol "strtok" 2066=error 017: undefined symbol "tmp" 2068=error 017: undefined symbol "ReturnUser"
// OnPlayerCommand
new tmp[128];
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;
}
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
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
}
#include a_samp
new
bool:TemPremiacao[ MAX_PLAYERS char]
;
public OnPlayerConnect(playerid){
return TemPremiacao{playerid} = false;
}
public OnPlayerCommandText(playerid, cmdtext[]){
if(strfind(cmdtext, "/darpermicaodragon", true) != -1){
if(strlen(cmdtext) == 18)
return SendClientMessage(playerid, -1, "/Darpremiacaodragon");
strdel(cmdtext, 0, 18);
if(!IsPlayerConnected(strval(cmdtext)))
return SendClientMessage(playerid, -1, "Player Nгo conectado");
static string[128], nome[24];
format(string, sizeof(string),"Vocк deu premiaзгo para o player %s(%s)", (GetPlayerName(strval(cmdtext), nome, 24), nome), cmdtext);
SendClientMessage(playerid, -1, string);
TemPremiacao { strval(cmdtext) } = true;
return true;
}
if(!strcmp(cmdtext, "/clandragonkit", true)){
if(TemPremiacao[playerid] != true)
return SendClientMessage(playerid, -1, "Vocк nгo tem permissгo para usar este comando!");
// coloque as armas aqui ;D
return true;
}
return false;
}
#Jonathan, acorda pra vida filho, strtok jб foi extinto faz tempo.
pawn Код:
|