Skip to content

Commit a7762ef

Browse files
authored
Merge pull request #1183 from NexiusTailer/master
Fix misleading info in porting post
2 parents d83ac48 + eba8825 commit a7762ef

File tree

1 file changed

+4
-73
lines changed

1 file changed

+4
-73
lines changed

frontend/blog/2024-03-06-porting.md

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,6 @@ public OnPlayerConnect(playerid)
9797
}
9898
```
9999
100-
## `ClearAnimations`
101-
102-
`ClearAnimations` is the dual of `ApplyAnimation` to stop a player performing the action previously requested. However, when used on a player in a vehicle this would also cause the player to be removed from the vehicle. This is a useful function, as it happens instantly, but is not within the purview of the `ClearAnimations` function. To force remove a player from a vehicle instantly use:
103-
104-
```c
105-
RemovePlayerFromVehicle(playerid, true);
106-
```
107-
108100
## Death money
109101
110102
When a player dies in San Andreas they get $100 deducted from them to cover hospital bills automatically. This feature remains in SA:MP, but is removed from open.mp to allow scripts to manage all their own money. Several scripts attempt to fix this already by adding $100 to a player after death, or on spawn. If this is your script simply delete the additional fix, although the code in open.mp does attempt to account for scripts that do this. If your script relied on this feature, simply add the following code to `OnPlayerDeath`:
@@ -113,67 +105,6 @@ When a player dies in San Andreas they get $100 deducted from them to cover hosp
113105
GivePlayerMoney(playerid, -100);
114106
```
115107

116-
## `OnPlayerConnect`
117-
118-
When a gamemode starts or restarts in SA:MP `OnPlayerConnect` is immediately called for all players already connected to the server, but it isn't when a filterscript starts or restarts. While the latter behaviour more closely matches the name, the former behaviour is extremely widely exploited in scripts, and so was extended to all script types in open.mp to maintain consistency.
119-
120-
Scripts which initialise data for a player no longer need to perform this code in two different locations:
121-
122-
```c
123-
public OnFilterScriptInit()
124-
{
125-
for (new playerid = 0; playerid != MAX_PLAYERS; ++playerid)
126-
{
127-
if (IsPlayerConnected(playerid))
128-
{
129-
InitialisePlayer(playerid);
130-
}
131-
}
132-
}
133-
134-
public OnPlayerConnect(playerid)
135-
{
136-
InitialisePlayer(playerid);
137-
}
138-
```
139-
140-
The loop in OnFilterScriptInit can now be removed:
141-
142-
```c
143-
public OnPlayerConnect(playerid)
144-
{
145-
InitialisePlayer(playerid);
146-
}
147-
```
148-
149-
If a script exploited this fact to only run code for new players joining the server after the scripts starts, and not for those who were on before, this will no longer work, but is again easilly fixed:
150-
151-
```c
152-
static bool:gAlreadyHere[MAX_PLAYERS];
153-
154-
public OnFilterScriptInit()
155-
{
156-
for (new playerid = 0; playerid != MAX_PLAYERS; ++playerid)
157-
{
158-
gAlreadyHere[playerid] = IsPlayerConnected(playerid);
159-
}
160-
}
161-
162-
public OnPlayerConnect(playerid)
163-
{
164-
if (gAlreadyHere[playerid])
165-
{
166-
gAlreadyHere[playerid] = false;
167-
}
168-
else
169-
{
170-
SendClientMessage(playerid, COLOUR_WARN, "You're late!");
171-
}
172-
}
173-
```
174-
175-
This may look to simply trade one loop in `OnFilterScriptInit` off for another one, but wanting to exclude current players from some code is a less common use-case than wanting to do something for everyone, so this is overall a net improvement; and as stated before vastly less invasive than not calling `OnPlayerConnect` in gamemodes.
176-
177108
## Game texts
178109

179110
SA:MP has six different game text styles, but several of them are basically unusable. One fades in and out constantly, one disappears after a set time regardless of the time you put, and one never disappears regardless of the time selected. However it turns out that all of these game text styles can be accurately[^1] reproduced using text draws. Thus fixes.inc and subsequently open.mp did so. The appearance of the game texts is the same as before, the advantage being that all styles are usable, with the downside being that they no longer fade in and out.
@@ -217,14 +148,14 @@ Though since the highest value is a real player when there are people online thi
217148

218149
## Spellings
219150

220-
SA:MP is very inconsistent in its code spellings - some things use English, some things use American:
151+
SA:MP is very inconsistent in its code spellings - some things use British English, some things use American:
221152

222-
- `Bumper` - English
153+
- `Bumper` - British
223154
- `Hood` - American
224-
- `Armour` - English
155+
- `Armour` - British
225156
- `Stereo` - American
226157

227-
We have unified these, and settled on English spellings. So for example:
158+
We have unified these, and settled on British spellings. So for example:
228159

229160
```c
230161
TextDrawBoxColor(Text:textid, boxColor);

0 commit comments

Comments
 (0)