[help] Car's system respawn problem - 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] Car's system respawn problem (
/showthread.php?tid=271436)
[help] Car's system respawn problem -
Dirkon - 24.07.2011
Hey everyone!
So I'm making a simple car system and I confronted with a little problem. The problem is that when I respawn vehicles second time, they get doubled.
Can anyone take a look at my script and say what's wrong, please?
Here's the server download link, so you could test it:
DOWNLOAD: With Server files ( Car system is a gamemode )
And if you don't like, here is just pastebin:
PASTEBIN: Just script
Re: [help] Car's system respawn problem -
Finn - 24.07.2011
Could be cuz you don't reset the
validcar[carid] variable when the vehicle is destroyed.
Re: [help] Car's system respawn problem -
Dirkon - 25.07.2011
thanks, that help.

But now there is another problem. When I respawn vehicles, Owner name in the file get's f*cked up. Let's say before respawn my name was:
and after respawn it is like:
Re: [help] Car's system respawn problem -
Finn - 29.07.2011
Sorry for late response, but I think I know that problem as well: you're using
strcat when you're copying the owner name, so it won't work like you want if the array isn't empty.
Use
strcpy by ****** instead (this function is from y_utils include which comes with YSI), it makes sure the destination will be empty before you start copying the text:
pawn Код:
#define strcpy(%0,%1,%2) \
strcat((%0[0] = '\0', %0), %1, %2)
Copy the function above on the top of your script and do:
pawn Код:
strcpy(CarInfo[carid][owner], ownername, MAX_PLAYER_NAME);
...You can also get YSI and include y_utils, I recommend that option.