Need help with a command. - 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: Need help with a command. (
/showthread.php?tid=105834)
Need help with a command. -
Striker_Moe - 31.10.2009
Hi there.
Iґve created 3 take-able turfs on my server. As a little extra, Iґve created a /turfs command which is supposed to show you the turfs and its occupations. Iґve started like this:
This is inside /turfs:
Код:
format(turf1, sizeof(turf1), ">> El Quebrados <<: Occupied by %s", zone1owned);
format(turf2, sizeof(turf2), ">> Gas Station <<: Occupied by %s", zone2owned);
format(turf3, sizeof(turf3), ">> Snake Farm <<: Occupied by %s", zone3owned);
This is when you successfully take a turf over (One example):
Then, at the top of the script:
Код:
#define USA 1
#define Germany 2
#define Russia 3
#define China 4
#define Civilians 5
#define Unoccupied 1227
At OnGameModeinit, Iґve setted all things to "unoccupied".
Now, when you type /turfs ingame, it displays some weird letters, but no occupations. Why?
Re: Need help with a command. -
Brendan_Thomson - 31.10.2009
Because you are trying to display a number as a string.
When you #define something as a number, then that's what it is when you use the definition. It's a number, so you're trying to format an integer as a string.
The #define is basically pasting that same bit of code (numbers or strings) wherever you put the definition.
Re: Need help with a command. -
Striker_Moe - 31.10.2009
Update: Tried it with the numbers, just like this:
zone3owned = 1;
But that wont work either - still those weird letters displayed.
Thanks for your answer Brendan. Do you have a solution how to get the names instead of integer displayed?
Re: Need help with a command. -
Striker_Moe - 31.10.2009
Anyone?
Re: Need help with a command. -
Nero_3D - 31.10.2009
That would be one way of doing it
pawn Код:
GetCountryName(zoneid)
{
switch(zoneid)
{
case 1: return "USA";
case 2: return "Germany";
case 3: return "Russia";
case 4: return "China";
case 5: return "Civilians";
default: return "Unoccupied";
}
}
pawn Код:
format(turf1, sizeof(turf1), ">> El Quebrados <<: Occupied by %s", GetCountryName(zone1owned));
format(turf2, sizeof(turf2), ">> Gas Station <<: Occupied by %s", GetCountryName(zone2owned));
format(turf3, sizeof(turf3), ">> Snake Farm <<: Occupied by %s", GetCountryName(zone3owned));