[pawn]
format(szMsg,sizeof(szMsg),"clanwar setted to loc to %s", GetPlayerLocation(playerid));
format(szMsg,sizeof(szMsg),"clanwar is now active of %s", tmp);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
[/pawn]
This violates rules of ordered instructions in programming and scripting. The script follows the code in the exact order that it is given. When you set the message in
szMsg twice in a row, and
then try to send both of your messages, you're going to end up with this:
clanwar is now active of my_war_area
clanwar is now active of my_war_areaWhat you need to do is format the first message, send it, and
then, and only then, can you format the second message and send that.
[pawn]
if(!strlen(tmp)) {
format(szMsg,sizeof(szMsg),"clanwar setted to loc to %s", GetPlayerLocation(playerid));
format(szMsg,sizeof(szMsg),"clanwar is now active of %s", tmp);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SetPlayerRandomJailSpawns(playerid);
} else {
format(szMsg,sizeof(szMsg),"clanwar setted to loc to %s", GetPlayerLocation(playerid));
format(szMsg,sizeof(szMsg),"clanwar is now active of %s", tmp);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SetPlayerRandomJailSpawns(playerid);
}
[/pawn]
The code in the
if and
else blocks do
exactly the same thing. This can easily be condensed, and there's no reason not to. Not only that, but you try to read the variable
tmp even when there is
nothing in it. This isn't even a situation where you haven't checked to see if there's anything in it. You checked to see if
tmp was empty, but even if it was, you ran the exact same code.
Based on the above suggestion as well, replace that entire thing with:
[pawn]
if( strlen( tmp ) )
{
format(szMsg,sizeof(szMsg),"clanwar setted to loc to %s", GetPlayerLocation(playerid));
SendClientMessage(playerid, COLOR_GREEN, szMsg);
format(szMsg,sizeof(szMsg),"clanwar is now active of %s", tmp);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SetPlayerRandomJailSpawns(playerid);
}
[/pawn]
[pawn]
GetPlayerLocation(playerid)
[/pawn]
This function was never included in your release. The code will not compile without it, making this a broken script. Add it.
[pawn]
SetPlayerRandomJailSpawns(playerid);
[/pawn]
This line of code will fundamentally break this release. First of all, you never even provided the function, and it is not included in GUPS, which this script is presumably based off of. Therefore, this won't even compile.
Secondly, even if you do include it, then what? How is the script supposed to know how to handle jail spawns? (Whatever that even
means -- none of this code was even explained in your post.) Then, what arrays and variables are supposed to keep track of it? Do these jail spawns get reset when players connect and disconnect?
All of that additional code would also have to be added to your post, and chances are, there is even
more code in that which would have to be posted, making this better suited for a full script release rather than a snippet that does absolutely nothing.
[pawn]
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
SendClientMessage(playerid, COLOR_GREEN, szMsg);
[/pawn]
What is the point of sending the message four times?
XD SEE BUGGS
Yes, I do. In the future, do your bugtesting on a blank GUPS script yourself instead of expecting us to do the work for you. Otherwise, you
will lose credibility.