If you have a 3GS on 3.1.3, the only way you can jailbreak is to downgrade your phone to 3.1.2, since Apple eliminated the USB exploit that used to make jailbreaking possible on the 3GS. Unfortunately, since Apple has stopped signing the 3.1.2 firmware, you can only downgrade if you have saved your 3.1.2 SHSH either on Saurik's server through Cydia or locally using Umbrella. If you don't, then there is no way to jailbreak your phone.