03.02.2016, 13:22
Hi! Can i request for /changename command that will change my name and update also my SQL table? Thanks!
new query[150];
strcat(query, "UPDATE `user_table` SET `name` = '");
strcat(query, new_name);
strcat(query, "' WHERE `name` = '");
strcat(query, old_name);
strcat(query, "'");
// run a query
pawn Код:
|
new query[150];
format(query,sizeof query,"UPDATE `user_table` SET `name` = '%s' WHERE `name` = '%s'",new_name,old_name);
CMD:g(playerid, params[]) { new s_gchat[145], gchat[145], t_gchat[145], playername[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername, sizeof(playername)); if (sscanf(params, "s[145]", gchat)) return SendClientMessage(playerid, -1, "{FFFFFF}Usage: {00FF00}/g <text>"); if (gchat_timer[playerid] < gettime()) { if (!Player[playerid][Title]) { gchat_timer[playerid] = gettime() + GCHAT_TIME; format(s_gchat, sizeof(s_gchat), "(( [%d] Level %d Player %s: %s ))", GetPlayerIdFromName(playername), Player[playerid][Score], GetName2(playerid), gchat); SendClientMessageToAll(COLOR_ORANGE, s_gchat); return 1; } else { gchat_timer[playerid] = gettime() + GCHAT_TIME; format(s_gchat, sizeof(s_gchat), "(( [%d] %s %s: %s ))", GetPlayerIdFromName(playername), Player[playerid][Title], GetName2(playerid), gchat); SendClientMessageToAll(COLOR_ORANGE, s_gchat); return 1; } } else { format(t_gchat, sizeof(t_gchat), "You must wait %i seconds before speaking again in this channel.", gchat_timer[playerid] - gettime()); SendClientMessage(playerid, COLOR_GREY, t_gchat); return 1; } } |
(([0] Test_Name: Hello)) |
(([0] Title Test Name: Hello)) |
(([0] Level 1 Player Test Name: Hello)) |
CMD:g(playerid,params[])
{
new string[145],nachricht[100],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
if(sscanf(params,"s[100]",nachricht))return SendClientMessage(playerid,-1,"Usage: {00FF00}/g <text>");
if(gchat_timer[playerid] < gettime())
{
if(!strlen(Player[playerid][Title]))
{
gchat_timer[playerid] = gettime() + GCHAT_TIME;
format(string,sizeof string,"(( [%d] Level %d Player %s: %s ))",playerid,Player[playerid][Score],playername,nachricht);
SendClientMessageToAll(COLOR_ORANGE,string);
return 1;
}
else
{
gchat_timer[playerid] = gettime() + GCHAT_TIME;
format(string,sizeof string,"(( [%d] %s %s: %s ))",playerid,Player[playerid][Title],playername,nachricht);
SendClientMessageToAll(COLOR_ORANGE,string);
return 1;
}
}
else
{
format(string,sizeof string,"You must wait %i seconds before speaking again in this channel.",gchat_timer[playerid] - gettime());
SendClientMessage(playerid,COLOR_GREY,string);
}
return 1;
}
@eikzdej:
Try this: PHP код:
|
format(string,sizeof string,"(( [%d] Level %d Player %s: %s ))",playerid,Player[playerid][Score],playername,nachricht); |