29.08.2015, 19:56
pawn Код:
CMD:fcreate(playerid,params[])
{
//new string[40],
new query[128], localfname[32];
if(sscanf(params,"s", localfname)) return SendClientMessage(playerid, -1, "Use: /fcreate [name]");
if(scorelevel[playerid] < 500) return SendClientMessage(playerid, COLOR_RED, "Vocк precisa ter score/level 500 para criar uma faction");
if(GetPlayerMoneyEx(playerid) < 500000) return SendClientMessage(playerid, COLOR_RED, "You do not have 500.000");
if(fmembro[playerid] > 0) return SendClientMessage(playerid, COLOR_RED, "Vocк jб tem uma faction");
format(query,sizeof query,"SELECT COUNT(*) AS exists FROM factions WHERE facname='%s'",localfname);
mysql_function_query(ConnectMYSQL,query,true,"r@MySQL_CheckFaction","ds",playerid, localfname);
// /\ importante deixar o cache como TRUE.
return 1;
}
public r@MySQL_CheckFaction(playerid, name[]) {
new field[11], exists;
cache_get_field_content(0, "exists", field, ConnectMYSQL);
exists = strval(field);
if(exists) {
// jб existe
return 1;
}
new query[128];
format(query, sizeof query, "INSERT INTO factions (facname) VALUES ('%s');", name);
mysql_function_query(ConnectMYSQL,query,true,"r@MySQL_CreateFaction","d",playerid);
return 1;
}
public r@MySQL_CreateFaction(playerid)
{
new novafacid = cache_insert_id(ConnectMYSQL);
fmembro[playerid] = novafacid;
fcargo[playerid] = 5;
GivePlayerMoneyEx(playerid,-500000);
SendClientMessage(playerid,-1,"Sua facзгo foi criada com sucesso!");
return 1;
}