[help] Car's system respawn problem
#1

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
Reply
#2

Could be cuz you don't reset the validcar[carid] variable when the vehicle is destroyed.
Reply
#3

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:
pawn Код:
Owner=Name_Lastname
and after respawn it is like:
pawn Код:
Owner=Name_LastnameName
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)