DB[playerid][Job]=strval("Unemployed");
#1

PHP код:
DB[playerid][Job]=strval("Unemployed"); 
this shit doesn't get anything, I mean the DB[playerid][Job] stays blank, I tried to make this function to check it:
PHP код:
new String[256];
format(String,sizeof(String),"Job: %s",DB[playerid][Job]);
SendClientMessage(playerid,-1,String); 
and it's just sending "Job: " which means the variable = nothing.

what should i do?

pls ignore my shitty english i wrote it in a minute and I was too lazy to take a look on the thread before posting it.
Reply
#2

Can you post the declaration of Job?
Reply
#3

Quote:
Originally Posted by BigBrainAFK
Посмотреть сообщение
Can you post the declaration of Job?
PHP код:
enum Database{
    
Blah,
    
Blah,
    
Job[30]
    
Blah,
    
Blah,

that's all.
Reply
#4

First read what strval does
https://sampwiki.blast.hk/wiki/Strval

Than read that
https://sampwiki.blast.hk/wiki/Scripting_Basics#Strings

If that doesn't work because of the enum use strcat with an empty string
https://sampwiki.blast.hk/wiki/Strcat
Reply
#5

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
First read what strval does
https://sampwiki.blast.hk/wiki/Strval

Than read that
https://sampwiki.blast.hk/wiki/Scripting_Basics#Strings

If that doesn't work because of the enum use strcat with an empty string
https://sampwiki.blast.hk/wiki/Strcat
PHP код:
new EmptyString[1];
DB[playerid][Job]=strcat(EmptyString,"Unemployed"); 
isn't working and I read the second link that u sent and i didnt understand what you want me to do with that info?
Reply
#6

pawn Код:
DB[playerid][Job][0] = EOS; // Clearing the string
strcat(DB[playerid][Job], "Unemployed", 30); // Adding "unemployed" to the now empty string.
Or use the strcpy macro, then you can do it with just one line:

pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)

strcpy(DB[playerid][Job], "Unemployed", 30);
Reply
#7

Quote:
Originally Posted by kvann
Посмотреть сообщение
pawn Код:
DB[playerid][Job][0] = EOS; // Clearing the string
strcat(DB[playerid][Job], "Unemployed", 30); // Adding "unemployed" to the now empty string.
Or use the strcpy macro, then you can do it with just one line:

pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)

strcpy(DB[playerid][Job], "Unemployed", 30);
oowah thanks man but when i do it with strcpy it's shows me this:
warning 201: redefinition of constant/macro (symbol "strcpy(%0,%1)")
Reply
#8

You don't need strcpy just change into:

format(DB[playerid][Job], /* HERE STRING SIZE */, "Unemployed");
Reply
#9

Quote:
Originally Posted by OwlIT
Посмотреть сообщение
You don't need strcpy just change into:

DB[playerid][Job] = "Unemployed";
smartass it won't work.
Reply
#10

Quote:
Originally Posted by Lirbo
Посмотреть сообщение
oowah thanks man but when i do it with strcpy it's shows me this:
warning 201: redefinition of constant/macro (symbol "strcpy(%0,%1)")
it is already defined in your script, just remove it.

I'm talking about this
pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)