SA-MP Forums Archive
help with orgname - 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: help with orgname (/showthread.php?tid=220283)



help with orgname - THE_KNOWN - 03.02.2011

Код:
CMD:request(playerid, params[])
{
	new id,name[MAX_PLAYER_NAME],tmp[128],string[128];
	if(sscanf(params,"i",id)) return SendClientMessage(playerid, red, "USAGE:/request [org]");
	GetPlayerName(playerid, name, sizeof(name));
	new query[128];
	format(query, sizeof(query), "SELECT * FROM orgs WHERE ID=%d",id);
	mysql_query(query);
 	mysql_store_result();
 	new row[128];
	new field[3][32];
    mysql_fetch_row_format(row, "|");
	explode(row, field, "|");
	tmp[127]=strval(field[1]);
	mysql_free_result();
	new query1[128];
	format(query1,sizeof(query1), "UPDATE ostats SET req=%d WHERE Name='%s'",id,name);
	mysql_query(query1);
	format(string, sizeof(string), "~%s is requesting to join %s.",name,tmp[127]);
	SendClientMessageToAll(COLOR_ORANGE, string);
	return 1;
}
it doesnt show the org name which is stored in the variable "tmp".


AW: help with orgname - Nero_3D - 03.02.2011

tmp[127] is the last cell of the array, since you save the number from field[1] in it I would say that you should use %d to print it


Re: help with orgname - THE_KNOWN - 03.02.2011

but im storing a name in tmp so isnt it supposed to be %s?


AW: Re: help with orgname - Nero_3D - 03.02.2011

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
but im storing a name in tmp so isnt it supposed to be %s?
where are you storing a name in tmp ? show me the line


Re: help with orgname - THE_KNOWN - 03.02.2011

tmp=strval(field[1])

there is a name in field 1


AW: Re: help with orgname - Nero_3D - 03.02.2011

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
tmp=strval(field[1])

there is a name in field 1
But you used strval (converts a string to an integer) :/

like you said the name is in field 1 so use field[1] in the format and remove tmp


Re: help with orgname - THE_KNOWN - 03.02.2011

can you edit the code for me? i didnt get you =P


AW: help with orgname - Nero_3D - 03.02.2011

Try it with that

pawn Код:
CMD:request(playerid, params[])
{
    if(sscanf(params, "i", params[0])) return SendClientMessage(playerid, red, "USAGE:/request [org]");
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(string, sizeof string, "UPDATE ostats SET req=%d WHERE Name='%s'", params[0], name);
    mysql_query(string);
    format(string, sizeof string, "SELECT * FROM orgs WHERE ID=%d", params[0]);
    mysql_query(string);
    mysql_store_result();
    mysql_fetch_row_format(string, "|");
    mysql_free_result();
    params[0] = (strfind(string, "|", false) + 1);
    string[strfind(string, "|", false, params[0])] = EOS;
    format(string, sizeof string, "~%s is requesting to join %s.", name, string[params[0]]);
    SendClientMessageToAll(COLOR_ORANGE, string);
    return 1;
}



Re: help with orgname - Danny - 03.02.2011

Sorry for going offtopic, but i mis-read the name of the thread. Instead of 'orgname' i read 'orgasm'. That makes me lol'd for an hour


Re: help with orgname - Steven Paul - 03.02.2011

Quote:
Originally Posted by -Danny-
Посмотреть сообщение
Sorry for going offtopic, but i mis-read the name of the thread. Instead of 'orgname' i read 'orgasm'. That makes me lol'd for an hour
It is not an off topic section. So don't give stupid replies