[HELP]World - 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)
+--- Thread: [HELP]World (
/showthread.php?tid=349600)
[HELP]World -
TheBluec0de - 09.06.2012
Help, how to make a world system, messages sent will receive only those in my own world ?
I tried to do it myself but I could not...
Re: [HELP]World -
Jonny5 - 09.06.2012
well show your code and we will try fix it.
Re: [HELP]World -
TheBluec0de - 09.06.2012
Quote:
Originally Posted by Jonny5
well show your code and we will try fix it.
|
OnPlayerText
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
// ...
}
return 0;
}
}
Re: [HELP]World -
JhnzRep - 09.06.2012
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
new str[128];
format(str, sizeof(str), "%s says: %s", GetPlayerName(playerid), text);
SendClientMessage(i, -1, str);
}
return 0;
}
}
EDIT:Changed params to text. Should work now.
Re: [HELP]World -
Jonny5 - 09.06.2012
your on your way!
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
SendClientMessage(i,-1,text);
}
}
}
return 0;
of course youll want to format the message with the senders name.
and return 0 at the end of the callback.
Re: [HELP]World -
TheBluec0de - 09.06.2012
Quote:
Originally Posted by JhnzRep
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid)) { new str[128]; format(str, sizeof(str), "%s says: %s", GetPlayerName(playerid), text); SendClientMessage(i, -1, str); } return 0; } }
EDIT:Changed params to text. Should work now.
|
other methods
?
Re: [HELP]World -
JhnzRep - 09.06.2012
What kind of other method would you want? Lol?
Re: [HELP]World -
Jonny5 - 09.06.2012
whats wrong with that, besides where he has the return 0;
that should be at the end of the callback not in the loop...
and GetPlayerName(playerid) cannot be used like that
Re: [HELP]World -
TheBluec0de - 09.06.2012
Quote:
Originally Posted by JhnzRep
What kind of other method would you want? Lol?
|
now the code works perfectly?
Re: [HELP]World -
JhnzRep - 09.06.2012
Quote:
Originally Posted by Jonny5
whats wrong with that, besides where he has the return 0;
that should be at the end of the callback not in the loop...
and GetPlayerName(playerid) cannot be used like that
|
1st, I didn't put the return there, he did. 2nd...Yea I know..It's really early here, and I haven't slept all night..
pawn Код:
new name[24];
GetPlayerName(playerid, name, sizeof(name));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
new str[128];
format(str, sizeof(str), "%s says: %s", name, text);
SendClientMessage(i, -1, str);
}
}
}
return 0;
Should work now.