SA-MP Forums Archive
DB[playerid][Job]=strval("Unemployed"); - 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)
+--- Thread: DB[playerid][Job]=strval("Unemployed"); (/showthread.php?tid=582691)



DB[playerid][Job]=strval("Unemployed"); - Lirbo - 22.07.2015

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.


AW: DB[playerid][Job]=strval("Unemployed"); - BigBrainAFK - 22.07.2015

Can you post the declaration of Job?


Re: AW: DB[playerid][Job]=strval("Unemployed"); - Lirbo - 22.07.2015

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

that's all.


AW: DB[playerid][Job]=strval("Unemployed"); - Nero_3D - 22.07.2015

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


Re: AW: DB[playerid][Job]=strval("Unemployed"); - Lirbo - 22.07.2015

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?


Re: DB[playerid][Job]=strval("Unemployed"); - kristo - 22.07.2015

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);



Re: DB[playerid][Job]=strval("Unemployed"); - Lirbo - 22.07.2015

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)")


Re: DB[playerid][Job]=strval("Unemployed"); - OwlIT - 22.07.2015

You don't need strcpy just change into:

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


Re: DB[playerid][Job]=strval("Unemployed"); - Lirbo - 22.07.2015

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

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


Re: DB[playerid][Job]=strval("Unemployed"); - xVIP3Rx - 22.07.2015

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)