SA-MP Forums Archive
sscanf prob - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: sscanf prob (/showthread.php?tid=186079)



sscanf prob - dark_clown - 27.10.2010

-.- just finished setscore from scratch that i made, if you want to have it take it
but help me im getting this problem
Код:
dcmd_setscore(playerid,params[])
{
	new string[128],score,id, pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
 	if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid, red, "ERROR: You must be level 3");
	if(sscanf(params,"ui[128]",id,score)) return SendClientMessage(playerid, ORANGE, "USAGE:/setscore[playerid][score]");
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player id");
	
	GetPlayerName(playerid, pName, sizeof(pName));
	GetPlayerName(id, pName2, sizeof(pName2));
	format(string, sizeof(string), "%s has changed your score to %i", pName, score);
	SendClientMessage(id, ORANGE, string);
	format(string, sizeof(string), "You have changed '%s' score to %i",pName2, score);
	SendClientMessage(playerid, ORANGE, string);
	SetPlayerScore(id, score);
	return 1;
}
no errors no warnings, but yes warnings on the console -.-

why?


Re: sscanf prob - armyoftwo - 27.10.2010

Код:
dcmd_setscore(playerid,params[])
{
	new string[128],score,id, pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
 	if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid, red, "ERROR: You must be level 3");
	if(sscanf(params,"ui",id,score)) return SendClientMessage(playerid, ORANGE, "USAGE:/setscore[playerid][score]");
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player id");
	
	GetPlayerName(playerid, pName, sizeof(pName));
	GetPlayerName(id, pName2, sizeof(pName2));
	format(string, sizeof(string), "%s has changed your score to %i", pName, score);
	SendClientMessage(id, ORANGE, string);
	format(string, sizeof(string), "You have changed '%s' score to %i",pName2, score);
	SendClientMessage(playerid, ORANGE, string);
	SetPlayerScore(id, score);
	return 1;
}
i[128] why?


Re: sscanf prob - Cameltoe - 27.10.2010

This should work:
pawn Код:
dcmd_setscore(playerid, params[])
{
    new string[128], pID, Score;
    if(sscanf(params, "ui", pID, Score) return SendClientMessage(playerid, Somecolor, "Usage: /setscore playerid / name - Score");
    SetPlayerScore(pID, Score);
    format(string, sizeof(string), "Admin: %s Changed your score to: %d",GetName(playerid),Score);
    SendClientMessage(pID, Somecolor, string);
    format(string, sizeof(string), "You changed : %s's Score to: %d",GetName(pID),Score);
    SendClientMessage(playerid, Somecolor, string);
    return 1;
}

stock GetPlayerNameEx(playerid)
{
    new pName[MAX_PLAYERS_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    return pName;
}