19.03.2012, 23:27
pode ser em strcmp?
si for pega ai:
si for pega ai:
pawn Код:
//no topo do gm:
new mudarnick[MAX_PLAYERS];
// nos comandos:
if(strcmp(cmd, "/mudarnome", true) == 0)
{
if(mudarnick[playerid] < 1) return SendClientMessage(playerid,-1,"Vc precisa de uma autorizaзгo para trocar de nick");
new arq[30],arq2[30],novonome[24],str[50];
novonome = strtok(cmdtext,idx);
if(!strlen(novonome)) return SendClientMessage(playerid,-1,"Uso: /mudarnome [nome]");
format(arq,sizeof(arq),"/contas/%s.ini",pName(playerid));
format(arq2,sizeof(arq2),"/contas/%s.ini",novonome);
frename(arq,arq2);
format(str,50,"Vocк mudou seu nome para: %s",novonome);
SendClientMessage(playerid,-1,str);
Kick(playerid);
mudarnick[playerid] = 0;
return 1;
}
if(strcmp(cmd, "/permitirmn", true) == 0)
{
if(pAdmin[playerid] < 3) return SendClientMessage(playerid,-1,"Vc nгo pode fazer isto.");
new id[50];
id = strtok(cmdtext,idx);
if(!strlen(id)) return SendClientMessage(playerid,-1,"Uso: /permitirmn [id]");
if(mudarnick[strval(id)] == 1) return SendClientMessage(playerid,-1,"Esse Player ja estб mudando de nick");
mudarnick[strval(id)] = 1;
return 1;
}
// no final do gm:
stock pName(playerid)
{
new name[25];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
frename(oldfile [], newfile []) // by [S]trong
{
if (!fexist(oldfile))
{
return print("Error: Could file not found!");
}
new String [256],
File: oldarchive = fopen(oldfile, io_read),
File: newarchive = fopen(newfile, io_write);
while (fread(oldarchive, String))
{
fwrite(newarchive, String);
}
fclose(newarchive);
fclose(oldarchive);
return fremove(oldfile);
}