Quote:
|
Ok,but as you said it removes only 500 $ from their money,but what about the points as you typed
|
I only now noticed my mistakes in code. I have corrected it. Thank you for pointing.
Quote:
|
How can I create function for points,that in game they will cost something,like the grenade cost 1,2 of points,but as I choose the HE grenade it doesn't bought me (I have removed all my money) in fact points are only in script
|
Ehm. This is basicly how it looks like. It's only an example and shouldn't acctualy be like that in your plugin. You can create it in your coding style.
===========================================
It looks like you didn't understand me well. I'll try to explain my code more clearly.
This is the place where points are stored for each player. It's an
array that holds points for each of the player on your server.
More about arrays here:
http://wiki.amxmodx.org/Pawn_Tutorial#Arrays
PHP Code:
new deathrun_points[32];
This is the
function that should be called if player clicks on the item in menu.
More about function here:
http://wiki.amxmodx.org/Pawn_Tutorial#Functions
PHP Code:
public myMenuItem(id, item) {
This is a
switch statement that swaps your items throw it's list. In our case it's item and it should contain 1.
More about switch statement:
http://wiki.amxmodx.org/Pawn_Tutorial#Switch_Statements
This is an
if check. I perform it to check if player with id have 2 points in HIS array deathrun_points[id].
More about if here:
http://wiki.amxmodx.org/Pawn_Tutorial#If_Statements
PHP Code:
if(deathrun_points[id] >= 2) {
And this is the final part.
Buy a grenade only with points.
PHP Code:
new deathrun_points[32];
public myMenuItem(id, item) {
switch(item) {
case 1: {
if(deathrun_points[id] >= 2) {
// bla bla...give grenade
// remove 2 points.
deathrun_points[id] = deathrun_points[id] - 2;
} else {
client_cmd(id,print_chat,"What the heck?! No points.");
}
}
// more other cool items.
}
}
Buy grenade with money and points.
PHP Code:
new deathrun_points[32];
public myMenuItem(id, item) {
new user_money = cs_get_user_money(id);
switch(item) {
case 1: {
if(user_money >= 500) {
// bla bla, give play grenade.
// this removes 500 from their money.
cs_set_user_money(id, user_money - 500);
} else if(deathrun_points[id] >= 2) {
// this removes 2 points from player.
deathrun_points[id] = deathrun_points[id] - 2;
} else {
client_cmd(1,print_chat,"Man, no money or points. Sorry, no grenade for you.");
}
}
// more other cool items.
}
}
If you understood everything, you could move to the next step. How to save and get the data.
Nvault or
MySQL. Else there's no point to continue.