- 0
[Ajutor] Problema script
-
Similar Content
-
- 8 replies
- 1,142 views
-
- 2 answers
- 163 views
-
- 2 answers
- 144 views
-
ajutor urgent
By R4zvyy,
- 1 answer
- 381 views
-
- 0 replies
- 77 views
-
-
Recently Browsing 0 members
- No registered users viewing this page.
Question
Klaudiu01
Nume: Klaudiu01
Problema: Dau compile si nu am nici o eroare, dar cand il pun pe server sa vad daca merge comenzile de admin functioneaza la oricine. :|
Eroare: [pawn]Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase[/pawn]
Script/Linii: [pawn] /****************************************************
* User System and some Admin Funtions *
* By Johny A.K.A Klaudiu *
* If you want to use this code in *
* your fs/gm leave credits! *
****************************************************/
//----------------------------=<[includes]>=------------------------------------
#include <a_samp>
#include <dini>
#include <dutils>
#pragma unused ret_memcpy
//----------------------------=<[Defines]>=-------------------------------------
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#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 COLOUR_GREEN 0x33AA33AA
#define COLOUR_RED 0xAA3333AA
#define COLOUR_YELLOW 0xFFFF00AA
#define COLOUR_LIGHTBLUE 0x33CCFFAA
#define COLOUR_ORANGE 0xFFFFFFAA
//#define MAX_PLAYERS 500
#define NO_ADMIN "Ne pare rau, nu esti un admin!"
#define PASS_FAIL "[{FF0000}EROARE{FFFFFF}]: Parola gresita!"
#define FUCK_YOU "Sugi pula, AI PRIMIT BAN!"
#define PlayerFile "AdminScript/Users/%s.ini"
#define SettingFile "AdminScript/Settings/MainSettings.ini"
#define CommandFile "AdminScript/Settings/Commands.ini"
/*enum PLAYER_MAIN_INFO
{
P_NAME[MAX_PLAYER_NAME],
P_IP,
P_REGGED,
P_PASS,
P_LOGGED,
P_LEVEL,
P_WIRED,
P_JAILED
}
new GlobalPlayerInfo[MAX_PLAYERS][PLAYER_MAIN_INFO];*/
enum SETTINGS_MAIN {
POCKET_MONEY,
JAIL_COMMANDS,
ANNOUNCE_SECONDS,
PASS_MIN,
PASS_MAX
}
new gSettings[sETTINGS_MAIN];
enum COMMANDS_MAIN {
AKILL,
ANNOUNCE,
ARMOURALL,
BAN,
CARHP,
EXPLODE,
FLIP,
GOTO,
GETHERE,
GIVEARMOUR,
GIVEHEALTH,
GIVEWEAPON,
GOD,
HEALALL,
IMITATE,
IP,
KICK,
MAXAMMO,
PING,
SETLEVEL,
SETWANTED,
TBAN,
TIME,
WEATHER
}
new gCommands[COMMANDS_MAIN];
//----------------------------=<[OnFilterScriptInit]>=--------------------------
public OnFilterScriptInit()
{
print("**********************************");
print("* Admin/User FS by Johny *");
print("**********************************");
if(!fexist(SettingFile))
{
dini_Create(SettingFile);
dini_IntSet(SettingFile, "PocketMoney", 100000);
dini_IntSet(SettingFile, "JailCommands", 0);
dini_IntSet(SettingFile, "AnnounceSeconds", 3);
dini_IntSet(SettingFile, "PassMin", 3);
dini_IntSet(SettingFile, "PassMax", 15);
}
gSettings[POCKET_MONEY] = dini_Int(SettingFile, "PocketMoney");
gSettings[JAIL_COMMANDS] = dini_Int(SettingFile, "JailCommands");
gSettings[ANNOUNCE_SECONDS] = dini_Int(SettingFile, "AnnounceSeconds");
gSettings[PASS_MIN] = dini_Int(SettingFile, "PassMin");
gSettings[PASS_MAX] = dini_Int(SettingFile, "PassMax");
if(!fexist(CommandFile))
{
dini_Create(CommandFile);
dini_IntSet(CommandFile, "Akill", 6);
dini_IntSet(CommandFile, "Announce", 5);
dini_IntSet(CommandFile, "Armourall", 3);
dini_IntSet(CommandFile, "Ban", 9);
dini_IntSet(CommandFile, "Carhp", 4);
dini_IntSet(CommandFile, "Explode", 5);
dini_IntSet(CommandFile, "Goto", 4);
dini_IntSet(CommandFile, "Gethere", 5);
dini_IntSet(CommandFile, "Givearmour", 6);
dini_IntSet(CommandFile, "Givehealth", 6);
dini_IntSet(CommandFile, "Giveweapon", 7);
dini_IntSet(CommandFile, "God", 10);
dini_IntSet(CommandFile, "Healall", 7);
dini_IntSet(CommandFile, "Imitate", 8);
dini_IntSet(CommandFile, "Ip", 2);
dini_IntSet(CommandFile, "Kick", 7);
dini_IntSet(CommandFile, "Maxammo", 8);
dini_IntSet(CommandFile, "Ping", 1);
dini_IntSet(CommandFile, "Setlevel", 10);
dini_IntSet(CommandFile, "Setwanted", 6);
dini_IntSet(CommandFile, "Tban", 9);
dini_IntSet(CommandFile, "Time", 3);
dini_IntSet(CommandFile, "Weather", 3);
}
gCommands[AKILL] = dini_Int(CommandFile, "Akill");
gCommands[ANNOUNCE] = dini_Int(CommandFile, "Announce");
gCommands[ARMOURALL] = dini_Int(CommandFile, "Armourall");
gCommands[bAN] = dini_Int(CommandFile, "Ban");
gCommands[CARHP] = dini_Int(CommandFile, "Carhp");
gCommands[EXPLODE] = dini_Int(CommandFile, "Explode");
gCommands[GOTO] = dini_Int(CommandFile, "Goto");
gCommands[GETHERE] = dini_Int(CommandFile, "Gethere");
gCommands[GIVEARMOUR] = dini_Int(CommandFile, "Givearmour");
gCommands[GIVEHEALTH] = dini_Int(CommandFile, "Givehealth");
gCommands[GIVEWEAPON] = dini_Int(CommandFile, "Giveweapon");
gCommands[GOD] = dini_Int(CommandFile, "God");
gCommands[HEALALL] = dini_Int(CommandFile, "Healall");
gCommands[iMITATE] = dini_Int(CommandFile, "Imitate");
gCommands[iP] = dini_Int(CommandFile, "Ip");
gCommands[KICK] = dini_Int(CommandFile, "Kick");
gCommands[MAXAMMO] = dini_Int(CommandFile, "Maxammo");
gCommands[sETLEVEL] = dini_Int(CommandFile, "Setlevel");
gCommands[sETWANTED] = dini_Int(CommandFile, "Setwanted");
gCommands[TBAN] = dini_Int(CommandFile, "Tban");
gCommands[TIME] = dini_Int(CommandFile, "Time");
gCommands[WEATHER] = dini_Int(CommandFile, "Weather");
return 1;
}
#endif
//----------------------------=<[Enums]>=---------------------------------------
enum PLAYER_MAIN_INFO
{
P_NAME[MAX_PLAYER_NAME],
P_IP,
P_REGGED,
P_PASS,
P_LOGGED,
P_LEVEL,
P_WIRED,
P_JAILED
}
new GlobalPlayerInfo[MAX_PLAYERS][PLAYER_MAIN_INFO];
/*enum SETTINGS_MAIN {
POCKET_MONEY,
JAIL_COMMANDS,
ANNOUNCE_SECONDS,
PASS_MIN,
PASS_MAX
}
new gSettings[sETTINGS_MAIN];
enum COMMANDS_MAIN {
AKILL,
ANNOUNCE,
ARMOURALL,
BAN,
CARHP,
EXPLODE,
FLIP,
GOTO,
GETHERE,
GIVEARMOUR,
GIVEHEALTH,
GIVEWEAPON,
GOD,
HEALALL,
IMITATE,
IP,
KICK,
MAXAMMO,
PING,
SETLEVEL,
SETWANTED,
TBAN,
TIME,
WEATHER
}
new gCommands[COMMANDS_MAIN]; */
//----------------------------=<[Global {new}]>=--------------------------------
//----------------------------=<[OnPlayerConnect]>=-----------------------------
public OnPlayerConnect(playerid)
{
new file[100],Name[MAX_PLAYER_NAME],Ip[16];
GetPlayerName(playerid,Name,sizeof(Name));
GetPlayerIp(playerid,Ip,sizeof(Ip));
format(file,sizeof(file),PlayerFile,Name);
if(!dini_Exists(file))
{
dini_Create(file);
dini_Set(file,"Name",Name);
dini_Set(file,"Ip",Ip);
dini_IntSet(file,"Registered",-1);
dini_IntSet(file,"Password",0);
dini_IntSet(file,"Level",0);
dini_IntSet(file,"Wired",0);
dini_IntSet(file,"Jailed",0);
SendClientMessage(playerid,COLOUR_ORANGE,"Se pare ca esti nou pe server! Foloseste /register <password>");
}
strcat(GlobalPlayerInfo[playerid][P_NAME], dini_Get(file,"Name"));
strcat(GlobalPlayerInfo[playerid][P_IP], dini_Get(file,"Ip"));
GlobalPlayerInfo[playerid][P_REGGED] = dini_Int(file,"Registered");
GlobalPlayerInfo[playerid][P_PASS] = dini_Int(file,"Password");
GlobalPlayerInfo[playerid][P_LEVEL] = dini_Int(file,"Level");
GlobalPlayerInfo[playerid][P_WIRED] = dini_Int(file,"Wired");
GlobalPlayerInfo[playerid][P_JAILED] = dini_Int(file,"Jailed");
if(GlobalPlayerInfo[playerid][P_REGGED] == 0) SendClientMessage(playerid,COLOUR_ORANGE,"Tu nu te-ai inregistrat inca! Foloseste /register <password>");
else if(GlobalPlayerInfo[playerid][P_REGGED] == 1) SendClientMessage(playerid,COLOUR_ORANGE,"Tu esti in inregistrat in baza de date. Foloseste /login <password>");
GlobalPlayerInfo[playerid][P_REGGED] = 0;
return 1;
}
//----------------------------=<[OnPlayerDisconect]>=---------------------------
public OnPlayerDisconnect(playerid, reason)
{
new file[100];
format(file,sizeof(file),PlayerFile,GlobalPlayerInfo[playerid][P_NAME]);
dini_Set(file,"Name",GlobalPlayerInfo[playerid][P_NAME]);
dini_Set(file,"Ip",GlobalPlayerInfo[playerid][P_IP]);
dini_IntSet(file,"Registered",GlobalPlayerInfo[playerid][P_REGGED]);
dini_IntSet(file,"Password",GlobalPlayerInfo[playerid][P_PASS]);
dini_IntSet(file,"Level",GlobalPlayerInfo[playerid][P_LEVEL]);
dini_IntSet(file,"Wired",GlobalPlayerInfo[playerid][P_WIRED]);
dini_IntSet(file,"Jailed",GlobalPlayerInfo[playerid][P_JAILED]);
GlobalPlayerInfo[playerid][P_NAME] = 0;
GlobalPlayerInfo[playerid][P_IP] = 0;
GlobalPlayerInfo[playerid][P_REGGED] = 0;
GlobalPlayerInfo[playerid][P_LOGGED] = 0;
GlobalPlayerInfo[playerid][P_PASS] = 0;
GlobalPlayerInfo[playerid][P_LEVEL] = 0;
GlobalPlayerInfo[playerid][P_WIRED] = 0;
GlobalPlayerInfo[playerid][P_JAILED] = 0;
return 1;
}
//----------------------------=<[OnFilterScriptExit]>=--------------------------
//----------------------------=<[OnDialogResponse]>=----------------------------
//----------------------------=<[OnPlayerCommandText]>=-------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new tmp[256];
new id;
dcmd(register, 8, cmdtext);
dcmd(login, 5, cmdtext);
dcmd(password, 8, cmdtext);
dcmd(help, 4, cmdtext);
dcmd(announce, 8, cmdtext);
if(strcmp(cmdtext, "/ban", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
id = ReturnUser(tmp);
if(GlobalPlayerInfo[playerid][P_LEVEL] < gCommands[bAN])
{
new string[256];
format(string, sizeof(string), "Esti admin %d? Nu deci, stai la locu tau!", gCommands[bAN]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
if(IsPlayerConnected(id) && id != playerid)
{
new string[256];
format(string, sizeof(string), "%s a primit ban!", GlobalPlayerInfo[id][P_NAME]);
SendClientMessageToAll(COLOUR_ORANGE, string);
Ban(id);
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "Nu iti poti da ban tie sau la un player care nu ii pe server!");
}
return 1;
}
if(strcmp(cmdtext, "/kick", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
id = ReturnUser(tmp);
if(GlobalPlayerInfo[playerid][P_LEVEL] < gCommands[KICK])
{
new string[256];
format(string, sizeof(string), "Esti admin %d? Nu deci, stai la locu tau!", gCommands[KICK]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
if(IsPlayerConnected(id) && id != playerid)
{
new string[256];
format(string, sizeof(string), "%s a primit kick!", GlobalPlayerInfo[id][P_NAME]);
SendClientMessageToAll(COLOUR_ORANGE, string);
Ban(id);
}
else
{
SendClientMessage(playerid, COLOUR_ORANGE, "Nu iti poti da kick tie sau la un player care nu ii pe server!");
}
}
return 1;
}
if(strcmp(cmdtext, "/kill", true) == 0)
{
tmp = strtok(cmdtext, idx);
id = ReturnUser(tmp);
if(GlobalPlayerInfo[playerid][P_LEVEL] < gCommands[AKILL])
{
new string[256];
format(string, sizeof(string), "Ai admin level %d? Nu deci stai la locul tau!", gCommands[AKILL]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
else if(!strlen(tmp))
{
SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}FOLOSIRE{FFFFFF}]: {00FF15}/kill {0000FF}[id | name]");
}
else
{
if(IsPlayerConnected(id) && id != playerid)
{
SetPlayerHealth(id, 0.0);
new string[256];
format(string, sizeof(string), "$s ti-a dat headshot de la 5 km distanta!.", GlobalPlayerInfo[playerid][P_NAME]);
SendClientMessage(id, COLOUR_ORANGE, string);
format(string, sizeof(string), "L-ai omorat pe %s.", GlobalPlayerInfo[id][P_NAME]);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Nu poti omora un player care nu este pe server.");
}
}
}
return 0;
}
dcmd_register(playerid, params[])
{
if(GlobalPlayerInfo[playerid][P_REGGED] == 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}ERROR{FFFFFF}]: You have already registered!");
else if(!params[0])
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}FOLOSIRE{FFFFFF}]: /register [password]");
else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
{
new string[128];
format(string, sizeof(string), "ERROR: Password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
else
{
new password = num_hash(params);
GlobalPlayerInfo[playerid][P_PASS] = password;
GlobalPlayerInfo[playerid][P_REGGED] = 1;
GlobalPlayerInfo[playerid][P_LOGGED] = 1;
GetPlayerIp(playerid, GlobalPlayerInfo[playerid][P_IP], 16);
new string[128]; format(string, sizeof(string), "Te-ai inregistrat in baza de date cu success folosing parola | {FF0000}%s {FFFFFF}|. Ai fost logat automat!", params);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
}
}
dcmd_login(playerid, params[])
{
if(GlobalPlayerInfo[playerid][P_REGGED] != 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}[EROARE{FFFFFF}]: Tu nu esti inregistrat!");
else if(GlobalPlayerInfo[playerid][P_LOGGED] == 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}[EROARE{FFFFFF}]: Tu esti deja logat!");
else if(!params[0])
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}FOLOSIRE{0000FF}]: /login {00FF00}[password]");
else
{
new password = num_hash(params);
if(GlobalPlayerInfo[playerid][P_PASS] == password)
{
GlobalPlayerInfo[playerid][P_LOGGED] = 1;
GetPlayerIp(playerid, GlobalPlayerInfo[playerid][P_IP], 16);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "Te-ai conectat cu success!");
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, PASS_FAIL);
}
}
dcmd_password(playerid, params[])
{
if(GlobalPlayerInfo[playerid][P_REGGED] != 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}[EROARE{FFFFFF}]: Tu nu esti inregistrat!");
else if(GlobalPlayerInfo[playerid][P_LOGGED] == 0)
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}[EROARE{FFFFFF}]: Tu esti deja logat!");
else
{
new tmp[256],
tmp2[256],
index;
tmp = strtok(params, index);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}FOLOSIRE{0000FF}]: /password [password] [new password]");
tmp2 = strtok(params, index);
if(!strlen(tmp2))
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}FOLOSIRE{0000FF}]: /password [password] [new password]");
new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
if(GlobalPlayerInfo[playerid][P_PASS] == oldpassword)
{
if(oldpassword == newpassword)
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}[EROARE{FFFFFF}]: Noua parola nu poate fi egala cu parola veche intelegi?.");
else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
{
new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
GlobalPlayerInfo[playerid][P_PASS] = newpassword;
new string[128]; format(string, sizeof(string), "Ti-ai schimbat cu success parola din \'%s\' to \'%s\'.", tmp, tmp2);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}[EROARE{FFFFFF}]: Parola gresita!");
}
}
dcmd_help(playerid, params[])
{
#pragma unused params
SendClientMessage(playerid, COLOUR_ORANGE, "{FF0000}|**| {0000FF}CONT: {FFFFFF}/register {00FF00}* {FFFFFF}/login {00FF00}* {FFFFFF}/password {FF0000}|**|");
if(GlobalPlayerInfo[playerid][P_LEVEL] >= 1)
{
SendClientMessage(playerid, COLOUR_ORANGE, "{FF0000}|**| {0000FF}ADMIN: {FFFFFF}/ban {00FF00}*{FFFFFF}/kill {00FF00}*{FFFFFF}/announce {00FF00}*{FFFFFF}/kick {FF0000}|**|");
}
return 1;
}
/*dcmd_kill(playerid, params[])
{
new tmp[256];
tmp = strtok(cmdtext, idx);
id = ReturnUser(tmp);
if(GlobalPlayerInfo[playerid][P_LEVEL] < gCommands[AKILL])
{
new string[100];
format(string, sizeof(string), "Ai admin level %d? Nu deci stai la locul tau!", gCommands[AKILL]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
else if(!strlen(params))
return SendClientMessage(playerid, COLOUR_ORANGE, "[{FF0000}FOLOSIRE{FFFFFF}]: {00FF15}/kill {0000FF}[id | name]");
else
{
if(IsPlayerConnected(id) && id != playerid)
{
SetPlayerHealth(id, 0.0);
new string[128];
format(string, sizeof(string), "$s ti-a dat headshot de la 5 km distanta!.", GlobalPlayerInfo[playerid][P_NAME]);
SendClientMessage(id, COLOUR_ORANGE, string);
format(string, sizeof(string), "L-ai omorat pe %s.", GlobalPlayerInfo[id][P_NAME]);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Nu poti omora un player care nu ii pe server.");
}
}*/
dcmd_announce(playerid, params[])
{
if(GlobalPlayerInfo[playerid][P_LEVEL] < gCommands[ANNOUNCE])
{
new string[100];
format(string, sizeof(string), "Esti admin %d? Nu, deci stai la locul tau!", gCommands[ANNOUNCE]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
else if(!strlen(params))
return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /announce [message]");
else
return GameTextForAll(params, gSettings[ANNOUNCE_SECONDS] * 1000, 3);
}
/*dcmd_ban(playerid, params[])
{
new tmp[256];
tmp = strtok(cmdtext, idx);
id = ReturnUser(tmp);
if(GlobalPlayerInfo[playerid][P_LEVEL] < gCommands[bAN])
{
new string[100];
format(string, sizeof(string), "Esti admin %d? Nu deci, stai la locu tau!", gCommands[bAN]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
if(IsPlayerConnected(id) && id != playerid)
{
new string[100];
format(string, sizeof(string), "%s a primit ban!", GlobalPlayerInfo[id][P_NAME]);
SendClientMessageToAll(COLOUR_ORANGE, string);
Ban(id);
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "Nu iti poti da ban tie sau la un player care nu ii pe server!");
}
dcmd_kick(playerid, params[])
{
new tmp[256];
tmp = strtok(cmdtext, idx);
id = ReturnUser(tmp);
if(GlobalPlayerInfo[playerid][P_LEVEL] < gCommands[KICK])
{
new string[100];
format(string, sizeof(string), "Esti admin %d? Nu deci, stai la locu tau!", gCommands[KICK]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
if(IsPlayerConnected(id) && id != playerid)
{
new string[100];
format(string, sizeof(string), "%s a primit kick!", GlobalPlayerInfo[id][P_NAME]);
SendClientMessageToAll(COLOUR_ORANGE, string);
Ban(id);
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "Nu iti poti da kick tie sau la un player care nu ii pe server!");
}*/
stock 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))
{
userid = INVALID_PLAYER_ID;
}
else
{
return userid; // A player was found
}
}
}
// 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
}
else // Partial match
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count)
{
SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow search.");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "No matching user found.");
}
}
userid = INVALID_PLAYER_ID;
}
return userid; // INVALID_PLAYER_ID for bad return
}
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string > '9' || string < '0') return 0;
}
return 1;
}[/pawn]
Ai incercat sa il rezolvi singur?: Da
Link to comment
Share on other sites
3 answers to this question
Recommended Posts