Help with script
#1

hello everyone i make a a dinamic setplayermap and addstaticpickup i make the script but i need help with how to load the ready created icons and pickups here is the script
http://pastebin.com/Nin38EaK
Reply
#2

Have you looked at:

https://sampwiki.blast.hk/wiki/Fread
Reply
#3

But what will happen
PHP код:
public OnFilterScriptInit()
{
     new 
string[64]; // Create the string to store the read text in
    
new File:example fopen("MapIcon.txt"io_read); // Open the file
    
fread(examplestring); // Fread from the file and store what's read in 'string'
    
fclose(example); // Close the file
    
printf("%s",string); // Print what was read
    
return 1;
}
public 
OnPlayerConnect(playerid)
{
    new 
string[64]; // Create the string to store the read text in
    
new File:example fopen("MapIcon.txt"io_read); // Open the file
    
while(fread(examplestring)) //reads the file line-by-line
    
{
        if(
strcmp(string"SetPlayerMapIcon"true) == 0//if any of the lines in the file say "Ban" the system will ban the player
        
{
            
SetPlayerMapIcon(playerid);
        }
    }
    
fclose(example);
    return 
1;

i make this but didn't load
Reply
#4

It's hard to explain, many people know but probably don't will help you.

If you want a suggestion, see how it works in similar scripts.
Reply
#5

do not have to explain it just i wont to make it i will understand how it stant
Reply
#6

Read the wiki about file functions, it should help you.
Once you understand how they work, you need to use a few string functions:
-strcmp: you will need to check if the line starts with "SetPlayerMapIcon(playerid,"
-a modified version of strtok, that will fetch your data basing on the comas (",") instead of the blanks

Like cynic said, every scripter has his habits when it comes to deal with files, and it's not easy to explain how it works if you haven't tried anything by yourself. There are systems that are more efficient than others though.

I myself use a system that consists in skipping all lines that don't start with the awaited pattern (for your case it's "SetPlayerMapIcon(playerid,"), with the help of strcmp. Then I start extracting every number using the function similar to strtok(string,idx) and I store every of these numbers in a var. Once I got all the numbers, I use the awaited function (in your case, SetPlayerMapIcon) with the help of all those vars that were holding the different vallues.

Just one thing: you'll need a loop. Dunno if it's explained in the wiki, but to go through each line you'll need to use something like that:
Код:
while (fread(ReadFile,line))
{
    // Process the content of "line" here
}
It's up to you to develop your own method to read through files.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)