"destroying" an array row.
#1

Well, I'll try to explain myself properly. I'm asking if it's possible to :

Lets say I got this array. (example: i'm not really doing this).

new PlayerStuff[MAX_PLAYERS]

PlayerStuff[0] = "Money";
PlayerStuff[1] = "Weapons";
PlayerStuff[3] = "Drugs";
PlayerStuff[4] = "Other";
etc...

Now, I want for example "weapons" removed, but I want this as result :

PlayerStuff[0] = "Money";
PlayerStuff[1] = "Drugs";
PlayerStuff[3] = "Other";
etc..

So, I actually want to delete the content of the array-row, and reduce the index of the follow element rows by 1.

Well if this is possible (For all the stuff in my array, there is a txt file, I need that txt file removed (dini_remove) but, besides that, i need the following txt names also reduced by 1.) names of the txt files are just like 1,2,3,4 etc.

Sorry, I couldn't really explain myself properly, I hope you get the idea. Thanks for any feedback.
Reply
#2

This is not possible in Pawn. At least not in an easy way. Furthermore, renaming a file means copying all contents of the old file to a new file with the designated name and deleting the old file afterwards.
Reply
#3

Quote:
Originally Posted by Vince
View Post
This is not possible in Pawn. At least not in an easy way. Furthermore, renaming a file means copying all contents of the old file to a new file with the designated name and deleting the old file afterwards.
And whats the not simple way then?
Reply
#4

1. By hand
2. Delete element, loop through all remaining elements, change their index and rename their filename to corresponding index.
Reply
#5

Means you 'll need an algorithm to copy the contents of index x to index x-1. However, you cannot actually decrease an array's total size, since it's set statically at compile time.
Reply
#6

So, basicly, this is impossible?
Reply
#7

Quote:
Originally Posted by JamesS
View Post
So, basicly, this is impossible?
Quote:
Originally Posted by Vince
View Post
This is not possible in Pawn.
You tell me.
Reply
#8

Quote:
Originally Posted by LarzI
View Post
You tell me.
Quote:
Originally Posted by Vince
View Post
At least not in an easy way.
Uhhh..
Reply
#9

pawn Code:
new Sacrifice[4][4] = {
    "Yay",
    "Op",
    "Is",
    "Yay"
};

//Blargh. Let's kill OP
new target = 1;
Sacrifice[target][0] = EOS;
for(new i = target + 1; i < sizeof Sacrifice; ++i) {
    if(Sacrifice[i][0] == EOS) continue;
    strcat(Sacrifice[i-1], Sacrifice[i]);
    Sacrifice[i][0] = EOS;
}
Add additional file renaming, and done
Reply
#10

You can use the CSTL plugin for example - it provides you with vectors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)