ECD amount check

Started by Nihongo^, Aug 29, 2016, 08:29 AM

Previous topic - Next topic

Nihongo^

hi im working on ECD ( European city dolor ) i'm little bit confused
i want convert dolors  to ecd i just want that function which can check the amount and  convert it to ecd
like 1 ecd = 10000$  if i  type /ecd 1 it decrease the cash if i type /ecd 2 it decrease more cash and convert it

KAKAN

Why copy paste?
And as well, it's the wrong board.
here's an example anyways:-
local amount = 2;
player.Cash -= 10000*amount;
oh no

Nihongo^

#2
Quote from: KAKAN on Aug 29, 2016, 08:38 AMWhy copy paste?
And as well, it's the wrong board.
here's an example anyways:-
local amount = 2;
player.Cash -= 10000*amount;
sry if i post in wrong section btw i'm still confused can you explain  little bit more  about this code plus how this code can help
if i type /ecd 10 30

KAKAN

#3
sure.
take this as an example command:-
http://pastebin.com/NSeRqzzT
Now, just by seeing, you can understand it.
:edit: I just saw that you PM'ed me with a message that you're weak in English, so, read this message( written in hindi ):
pehele ham ye dekh rahe hen ki wo kuch value dia hey ya nahi aur agar dia hai toh wo ek number hey ya nahi. Agar he toh, ham uska money check kar rahe hen, agar kam he to, usko kuch nahi milega, aur agar theek hey to, phir usko uska ECDs mil jayega.
NOTE:- I'm not good in hindi though
oh no

Nihongo^

#4
Dude my english isn't weak enough O.o
btw
Thanks kakan this example help a lot :D problem almost solved just 1 thing left
i saved ecd in database in db the ecd are updating but not in game you have to rejoin the server for updating
+
i got this error



else if( cmd == "ecd" )
 {

        if(!text) return MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E] Added soon.", player );
        else if( !IsNum( text ) ) return MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]added soon .", player );
        else {
            //Convert the text to integer.
            text = text.tointeger();
            //The required cash.
            local newamount = 100*text;
            //Check if the player has sufficient money or not.
            if( player.Cash < newamount ) return MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]added soon.", player );
            //tell the message.
             MessagePlayer("You've got " + text + " ECDs for exchange of: $" + newamount , player );
DecCash( player, newamount );
            //Give them the ECD somehow.
Incecd(player, text )

        }
    }
here my cmd

EK.IceFlake


Nihongo^

Quote from: EK.CrystalBlue on Aug 29, 2016, 11:15 AMLine?
it does not show the line number or any error just appeared this 

Xmair

Quote from: Nihongo^ on Aug 29, 2016, 11:29 AM
Quote from: EK.CrystalBlue on Aug 29, 2016, 11:15 AMLine?
it does not show the line number or any error just appeared this 
Try removing the try catch lines from your onPlayerCommand function.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Kewun

Maybe you dont have inc ecd and dec ecd functions

Nihongo^

#9
Quote from: Xmair on Aug 29, 2016, 11:34 AM
Quote from: Nihongo^ on Aug 29, 2016, 11:29 AM
Quote from: EK.CrystalBlue on Aug 29, 2016, 11:15 AMLine?
it does not show the line number or any error just appeared this 
Try removing the try catch lines from your onPlayerCommand function.
Thanks xmair its work here's the bug


Line 152
Quoteplayer.VC = PlayerVC( player );

EK.IceFlake

player.VC doesnt in the squirrel plugin, and you cant add it because player returning new instance every time for some reason

KAKAN

Quote from: EK.CrystalBlue on Aug 29, 2016, 12:33 PMplayer.VC doesnt in the squirrel plugin, and you cant add it because player returning new instance every time for some reason
lol?
Add this to the top of your script:-
CPlayer.rawnewmember( "VC", 0, null, false );You're done now :)
oh no

Nihongo^

Quote from: KAKAN on Aug 29, 2016, 12:49 PM
Quote from: EK.CrystalBlue on Aug 29, 2016, 12:33 PMplayer.VC doesnt in the squirrel plugin, and you cant add it because player returning new instance every time for some reason
lol?
Add this to the top of your script:-
CPlayer.rawnewmember( "VC", 0, null, false );You're done now :)
Thanks kakan for your reply
but
what is CPlayer ? and how this function belongs to my VC function

KAKAN

Quote from: Nihongo^ on Aug 29, 2016, 12:54 PM
Quote from: KAKAN on Aug 29, 2016, 12:49 PM
Quote from: EK.CrystalBlue on Aug 29, 2016, 12:33 PMplayer.VC doesnt in the squirrel plugin, and you cant add it because player returning new instance every time for some reason
lol?
Add this to the top of your script:-
CPlayer.rawnewmember( "VC", 0, null, false );You're done now :)
Thanks kakan for your reply
but
what is CPlayer ? and how this function belongs to my VC function

Well, the instance player which you use belongs to the CPlayer class. And that class contains all your functions in the player's instance.
You're using player.VC, and the 'VC' variable doesn't exist. So, you need to add it to the class yourself.
oh no

Nihongo^

Quote from: KAKAN on Aug 29, 2016, 01:00 PM
Quote from: Nihongo^ on Aug 29, 2016, 12:54 PM
Quote from: KAKAN on Aug 29, 2016, 12:49 PM
Quote from: EK.CrystalBlue on Aug 29, 2016, 12:33 PMplayer.VC doesnt in the squirrel plugin, and you cant add it because player returning new instance every time for some reason
lol?
Add this to the top of your script:-
CPlayer.rawnewmember( "VC", 0, null, false );You're done now :)
Thanks kakan for your reply
but
what is CPlayer ? and how this function belongs to my VC function

Well, the instance player which you use belongs to the CPlayer class. And that class contains all your functions in the player's instance.
You're using player.VC, and the 'VC' variable doesn't exist. So, you need to add it to the class yourself.
Thanks kakan i will try it but 1 thing left
i saved ecd in database in db the ecd are updating but not in game you have to rejoin the server for updating