Hello There, Guest! Login or Register


public doesn't work
#1
Hi All,

A short time ago I started to make a public function, but I still don't really get it.
I now have this:
Code:
public set_mysql_loggedin_level(pname, level)
{
       new giveplayerid[MAX_PLAYER_NAME];
    new prname[16];
    GetPlayerName(giveplayerid,prname,sizeof(prname));
    format(strlogin, sizeof(strlogin), "UPDATE users SET loggedin='%d' WHERE name = '%s'", level,prname);
    samp_mysql_query(strlogin);
    samp_mysql_store_result();
}

And what I think is, that I did it totally wrong!

What he needs to do is, if I do in a command in OnPlayerCommandText: set_mysql_loggedin_level(sendername, 0);
It needs to set/update the player level to 0. and if I insert 1 in the place of 0. It needs to be updated to 1. Don't look at the mysql-lines (format + 2 samp_mysql_), they are good.

I hope someone can help me! :)
Reply
#2
Err wrong section but im not sure what your trying to do

" I've tried reporting this thread to moderator but it keeps saying" " Hacking Atempt..."
Reply
#3
(04-22-2008, 09:30 PM)FarePak link Wrote: Err wrong section but im not sure what your trying to do

" I've tried reporting this thread to moderator but it keeps saying" " Hacking Atempt..."

why would you report to moderator... and Xanland, I dont understand what yo are asking!
Reply
#4
Why do you have to make it public? Can't you just call it normally?
Reply
#5
(04-22-2008, 09:33 PM)InVion link Wrote: why would you report to moderator... and Xanland, I dont understand what yo are asking!
because invion... thats what you're supposed to do, as an alternative to mini-modding like so many people do here..
Reply
#6
It's now like this:
Code:
set_mysql_loggedin_level(prname, level)
{
       new giveplayerid[MAX_PLAYER_NAME];
    new prname[MAX_PLAYER_NAME];
    GetPlayerName(giveplayerid,prname,sizeof(prname));
    format(strlogin, sizeof(strlogin), "UPDATE users SET loggedin='%d' WHERE name = '%s'", level,prname);
    samp_mysql_query(strlogin);
    samp_mysql_store_result();
}

Errors. If I use them like set_mysql_loggedin_level(sendername, 0); in OnPlayerCommandText. It gives this error:
Quote:E:\samp-server\8\gamemodes\xanland.pwn(156) : warning 219: local variable "prname" shadows a variable at a preceding level
E:\samp-server\8\gamemodes\xanland.pwn(157) : error 035: argument type mismatch (argument 1)
E:\samp-server\8\gamemodes\xanland.pwn(153) : warning 203: symbol is never used: "prname"
E:\samp-server\8\gamemodes\xanland.pwn(170) : error 035: argument type mismatch (argument 1)
E:\samp-server\8\gamemodes\xanland.pwn(701) : error 035: argument type mismatch (argument 1)

prname is only newly created in this function.
Reply
#7
xanland, you r way too more inteligent than us, i think you wont get help asking here  _O- _O-
Reply
#8
(04-24-2008, 12:00 AM)Motorola link Wrote: xanland, you r way too more inteligent than us, i think you wont get help asking here  _O- _O-

Don't be too hasty to assume ;)

Code:
set_mysql_loggedin_level(prname, level)
{
       new giveplayerid[MAX_PLAYER_NAME];
    new prname[MAX_PLAYER_NAME];
    GetPlayerName(giveplayerid,prname,sizeof(prname));
    format(strlogin, sizeof(strlogin), "UPDATE users SET loggedin='%d' WHERE name = '%s'", level,prname);
    samp_mysql_query(strlogin);
    samp_mysql_store_result();
}

Look at the variable declarations.
Your two variables are arrays.
The error "argument type mismatch" means that a function is not being passed the correct type of variable.
The variable "giveplayerid" should be an integer, not an array. The function GetPlayerName() will need to use an integer variable to check whose player's name to get.

Oh, by the way, don't use the script showroom for help threads. Those should go in the scripting section.
Reply
#9
(04-24-2008, 12:24 AM)Fry link Wrote: Look at the variable declarations.
Your two variables are arrays.
The error "argument type mismatch" means that a function is not being passed the correct type of variable.
The variable "giveplayerid" should be an integer, not an array. The function GetPlayerName() will need to use an integer variable to check whose player's name to get.

Oh, by the way, don't use the script showroom for help threads. Those should go in the scripting section.

Hey u r right those r arrays may be thats the problem
Reply
#10
(04-24-2008, 12:28 AM)Motorola link Wrote: Hey u r right those r arrays may be thats the problem
}:|
Reply