Las Venturas Playground
public doesn't work - Printable Version

+- Las Venturas Playground (https://forum.sa-mp.nl)
+-- Forum: Miscellaneous (https://forum.sa-mp.nl/forum-4.html)
+--- Forum: Gaming (https://forum.sa-mp.nl/forum-27.html)
+--- Thread: public doesn't work (/thread-8235.html)

Pages: 1 2


public doesn't work - Xanland - 04-22-2008

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! :)


Re: public doesn't work - FarePak - 04-22-2008

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


Re: public doesn't work - Danny - 04-22-2008

(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!


Re: public doesn't work - Fry - 04-22-2008

Why do you have to make it public? Can't you just call it normally?


Re: public doesn't work - HaZe - 04-22-2008

(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..


Re: public doesn't work - Xanland - 04-23-2008

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.


Re: public doesn't work - MoToRoLa - 04-24-2008

xanland, you r way too more inteligent than us, i think you wont get help asking here  _O- _O-


Re: public doesn't work - Fry - 04-24-2008

(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.


Re: public doesn't work - MoToRoLa - 04-24-2008

(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


Re: public doesn't work - Fry - 04-24-2008

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